From 4b11dfe9cd5bef68134f89e6d516e05930de38c5 Mon Sep 17 00:00:00 2001 From: KPal Date: Thu, 22 Oct 2026 13:18:04 +0100 Subject: [PATCH] ci: replace release.sh with a release workflow --- .github/workflows/release.yml | 57 +++++++++++++++++++++++++++++++++++ release.sh | 26 ---------------- 2 files changed, 57 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/release.yml delete mode 100755 release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8d9d259 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Release + +run-name: Release ${{ inputs.type }} + +on: + workflow_dispatch: + inputs: + type: + description: 'Version bump' + type: choice + options: [patch, minor, major] + default: patch + +jobs: + release: + name: Release + runs-on: ubuntu-latest + if: ${{ github.repository == 'playcanvas/attribute-parser' && github.ref_name == 'main' }} + # queue releases instead of racing them + concurrency: + group: release + cancel-in-progress: false + steps: + # tags pushed with GITHUB_TOKEN don't trigger the publish workflow + - name: Generate app token + id: app-token + uses: actions/create-github-app-token@v3 + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_KEY }} + + - name: Check out code + uses: actions/checkout@v7 + with: + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Set up Node.js + uses: actions/setup-node@v7 + with: + node-version: 24.x + + - name: Configure git + run: | + id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id) + git config user.name "${{ steps.app-token.outputs.app-slug }}[bot]" + git config user.email "${id}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com" + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + + - name: Tag release + run: | + tag=$(npm version "$TYPE") + git push --atomic origin HEAD:main "refs/tags/$tag" + echo "Released $tag" >> "$GITHUB_STEP_SUMMARY" + env: + TYPE: ${{ inputs.type }} diff --git a/release.sh b/release.sh deleted file mode 100755 index 82ee134..0000000 --- a/release.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -e - -TYPE=$1 - -if [[ ! " major minor patch " =~ " $TYPE " ]]; then - echo "Usage: $0 (major|minor|patch)" - exit 1 -fi - -# Fetch all remote tags -git fetch --tags - -# Calculate the next version -npm version $TYPE --preid=$PRE_ID_PREVIEW --no-git-tag-version >> /dev/null -NEXT_VERSION=$(npm pkg get version | sed 's/"//g') -git reset --hard >> /dev/null - -# Confirm release -read -p "About to release 'v$NEXT_VERSION'. Continue? (y/N) " -r -if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "Release cancelled." - exit 1 -fi - -# Tag release -npm version $TYPE \ No newline at end of file