chore(build): automated release process (#108)
* chore(build): automated release process * fix: update secret name to match current setup
This commit is contained in:
parent
8c24bdf905
commit
6068163419
83
.github/workflows/release.yml
vendored
83
.github/workflows/release.yml
vendored
@ -2,28 +2,85 @@ name: Release
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
tags:
|
||||||
- x_main # CI release temporarily disabled
|
- "*-[0-9]+.[0-9]+.[0-9]+*"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
package:
|
||||||
|
description: "Package to release"
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- client
|
||||||
|
- proxy
|
||||||
|
version:
|
||||||
|
description: "Version to release (e.g., 1.2.0, 1.3.0-alpha.0)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
dry_run:
|
||||||
|
description: "Dry run (will not publish to npm)"
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
build-and-publish:
|
||||||
name: Release
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: "16.x"
|
node-version: "20"
|
||||||
registry-url: "https://registry.npmjs.org"
|
registry-url: "https://registry.npmjs.org"
|
||||||
scope: "@fal"
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Publish to NPM
|
|
||||||
|
- name: Extract package info
|
||||||
|
id: tag-info
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
# Manual trigger
|
||||||
|
PACKAGE_NAME="${{ inputs.package }}"
|
||||||
|
VERSION="${{ inputs.version }}"
|
||||||
|
else
|
||||||
|
# Tag trigger
|
||||||
|
TAG_NAME=${{ github.ref_name }}
|
||||||
|
PACKAGE_NAME=$(echo $TAG_NAME | cut -d'-' -f1)
|
||||||
|
VERSION=$(echo $TAG_NAME | cut -d'-' -f2-)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract npm tag based on version qualifier
|
||||||
|
if [[ $VERSION =~ .*-([a-zA-Z]+)\.[0-9]+$ ]]; then
|
||||||
|
NPM_TAG="${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
NPM_TAG="latest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "package=$PACKAGE_NAME" >> $GITHUB_OUTPUT
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
run: npx nx build ${{ steps.tag-info.outputs.package }} --prod
|
||||||
|
|
||||||
|
- name: Verify package version
|
||||||
|
run: |
|
||||||
|
PACKAGE_JSON_VERSION=$(node -p "require('./dist/libs/${{ steps.tag-info.outputs.package }}/package.json').version")
|
||||||
|
if [ "$PACKAGE_JSON_VERSION" != "${{ steps.tag-info.outputs.version }}" ]; then
|
||||||
|
echo "Package version ($PACKAGE_JSON_VERSION) does not match tag version (${{ steps.tag-info.outputs.version }})"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Publish package
|
||||||
|
run: |
|
||||||
|
echo "Publishing ${{ steps.tag-info.outputs.package }}@${{ steps.tag-info.outputs.version }} with tag ${{ steps.tag-info.outputs.npm_tag }}"
|
||||||
|
cd dist/libs/${{ steps.tag-info.outputs.package }}
|
||||||
|
npm publish --access public --tag ${{ steps.tag-info.outputs.npm_tag }} ${{ inputs.dry_run && '--dry-run' || '' }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
||||||
run: npx nx release client
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user