Skip to content

Commit

Permalink
ci: 👷 Rework CI deploy process
Browse files Browse the repository at this point in the history
  • Loading branch information
CPlusPatch committed Aug 24, 2024
1 parent f65cfe4 commit e9fe689
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 44 deletions.
60 changes: 20 additions & 40 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,20 @@
name: Build & Publish Package

on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
version:
description: "Version to publish"
required: true
type: string
# Default to truncated commit hash
default: "0.0.0"
tag:
description: "Tag to publish"
required: true
type: string
default: "latest"
package:
description: "Package to publish"
options:
- federation
- client
type: choice
required: true
registry:
description: "Registry to publish to"
required: true
type: choice
options:
- npm
- jsr
- both
default: "both"
push:
branches:
- main

permissions:
contents: read
# For provenance generation
id-token: write

jobs:
# Build job
build:
publish:
runs-on: ubuntu-latest
environment: NPM Deploy
if: contains(github.event.head_commit.message, '[publish')
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -56,15 +29,22 @@ jobs:
- name: Build
run: bun install && bun run build

- name: Change version in package.json to ${{ github.event.inputs.version }}
run: 'sed -i ''s/"version": ".*"/"version": "${{ github.event.inputs.version }}"/'' package.json ${{ github.event.inputs.package }}/package.json ${{ github.event.inputs.package }}/jsr.jsonc'
- name: Publish Federation to NPM
if: contains(github.event.head_commit.message, '(federation)')
run: cd federation && npm publish --provenance --tag ${{ contains(github.event.head_commit.message, '[publish nightly]') && 'nightly' || 'latest' }} --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish Federation to JSR
if: contains(github.event.head_commit.message, '(federation)')
run: cd federation && bunx jsr publish --allow-slow-types --allow-dirty

- name: Publish to NPM
if: ${{ github.event.inputs.registry == 'npm' }} || ${{ github.event.inputs.registry == 'both' }}
run: cd ${{ github.event.inputs.package }} && npm publish --provenance --tag ${{ github.event.inputs.tag }} --access public
- name: Publish Client to NPM
if: contains(github.event.head_commit.message, '(client)')
run: cd client && npm publish --provenance --tag ${{ contains(github.event.head_commit.message, '[publish nightly]') && 'nightly' || 'latest' }} --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to JSR
if: ${{ github.event.inputs.registry == 'jsr' }} || ${{ github.event.inputs.registry == 'both' }}
run: cd ${{ github.event.inputs.package }} && bun install --frozen-lockfile && bunx jsr publish --allow-slow-types --allow-dirty
- name: Publish Client to JSR
if: contains(github.event.head_commit.message, '(client)')
run: cd client && bunx jsr publish --allow-slow-types --allow-dirty
2 changes: 1 addition & 1 deletion client/jsr.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://jsr.io/schema/config-file.v1.json",
"name": "@versia/client",
"version": "0.0.0",
"version": "0.0.1-alpha.1",
"exports": {
".": "./index.ts",
"./types": "./types.ts"
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@versia/client",
"displayName": "Versia Client",
"version": "0.0.0",
"version": "0.0.1-alpha.1",
"author": {
"email": "jesse.wierzbinski@lysand.org",
"name": "Jesse Wierzbinski (CPlusPatch)",
Expand Down
2 changes: 1 addition & 1 deletion federation/jsr.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://jsr.io/schema/config-file.v1.json",
"name": "@versia/federation",
"version": "0.0.0",
"version": "0.0.1-alpha.1",
"exports": {
".": "./index.ts",
"./types": "./schemas.ts"
Expand Down
2 changes: 1 addition & 1 deletion federation/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@versia/federation",
"displayName": "Versia Federation",
"version": "0.0.0",
"version": "0.0.1-alpha.1",
"author": {
"email": "jesse.wierzbinski@lysand.org",
"name": "Jesse Wierzbinski (CPlusPatch)",
Expand Down

0 comments on commit e9fe689

Please sign in to comment.