From c3d354640575ca59c5a74bf02c3676690c8e0f6f Mon Sep 17 00:00:00 2001 From: unnoq Date: Sun, 1 Dec 2024 07:02:28 +0700 Subject: [PATCH] feat: publish workflow 20 --- .github/workflows/publish.yaml | 71 ---------------------------------- .github/workflows/release.yaml | 65 +++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index 441198f..0000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,71 +0,0 @@ -name: Publish Packages - -on: - workflow_dispatch: - inputs: - bump: - required: true - type: choice - options: - - next - - patch - - minor - - major - - prepatch - - preminor - - premajor - - preid: - type: choice - required: true - default: beta - options: - - alpha - - beta - - canary - -jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: write - id-token: write - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: pnpm/action-setup@v4 - - - run: pnpm install - - - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - - - run: pnpm dlx bumpp -r ${{ github.event.inputs.bump }} --yes --preid=${{ github.event.inputs.preid }} - - - run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - - id: package-version - uses: martinbeentjes/npm-get-version-action@v1.3.1 - - # use steps.package-version.outputs.current-version for create - - - id: prerelease-tag - run: | - VERSION=${{ steps.package-version.outputs.current-version }} - - if [[ $VERSION =~ ^[0-9\.]+(-([0-9A-Za-z-]+).*)?$ ]]; then - echo "tag=${BASH_REMATCH[2]}" - else - echo "tag=unknown" - fi - - - run: pnpm --filter='./packages/*' -r publish --tag="${{ steps.prerelease-tag.outputs.tag || 'latest' }}" - - - run: pnpm dlx changelogithub - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..d96e9db --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,65 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Bump version (e.g., 4.0.0, 4.1.0-alpha.1, 5.0.0-beta.2)' + required: true + type: string + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + main: + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + steps: + + - id: version + run: | + VERSION="${{ github.event.inputs.version }}" + + if [[ $VERSION =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-([a-z]+)\.([1-9][0-9]*))?$ ]]; then + if [[ "${BASH_REMATCH[5]}" == "latest" ]]; then + echo "INVALID VERSION FORMAT ('latest' is not allowed): $VERSION" >&2 + exit 1 + fi + + echo "major=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT + echo "minor=${BASH_REMATCH[2]}" >> $GITHUB_OUTPUT + echo "patch=${BASH_REMATCH[3]}" >> $GITHUB_OUTPUT + echo "preid=${BASH_REMATCH[5]}" >> $GITHUB_OUTPUT + echo "number=${BASH_REMATCH[6]}" >> $GITHUB_OUTPUT + else + echo "INVALID VERSION FORMAT: $VERSION" >&2 + exit 1 + fi + + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: pnpm/action-setup@v4 + + - run: pnpm i + + - run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - run: pnpm dlx bumpp -r ${{ github.event.inputs.version }} --yes --preid=${{ steps.version.outputs.preid }} + + - run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - run: pnpm --filter='./packages/*' -r publish --tag="${{ steps.version.outputs.preid || 'latest' }}" + + - run: pnpm dlx changelogithub + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}