diff --git a/.github/workflows/apollo-server-plugin-release.yml b/.github/workflows/apollo-server-plugin-release.yml index 9f6f271..d0de90f 100644 --- a/.github/workflows/apollo-server-plugin-release.yml +++ b/.github/workflows/apollo-server-plugin-release.yml @@ -7,7 +7,8 @@ on: jobs: build: - name: Release Streamdal's Apollo Server Plugin + name: Tag and Release + if: ${{ !contains(github.event.head_commit.message, 'norelease') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@main @@ -21,6 +22,43 @@ jobs: - name: Install dependencies run: npm install --force + - name: Generate new tag (dry run) + uses: mathieudutour/github-tag-action@v6.1 + id: get_new_version + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + dry_run: true + fetch_all_tags: true + + - name: Update npm package version + run: | + npm --no-git-tag-version version ${{ steps.get_new_version.outputs.new_version }} + + # We do this because other jobs might have written to the repo while this + # job was running and making local changes; without this pull step, we + # might run into an error when performing the auto-commit. + - name: Pull latest changes + run: | + git config user.name github-actions + git config user.email github-actions@github.com + git pull --depth=10 + + - uses: stefanzweifel/git-auto-commit-action@v4 + id: auto_commit + with: + commit_message: Bumped npm package version to ${{ steps.get_new_version.outputs.new_version }} + + - name: Create tag + uses: mathieudutour/github-tag-action@v6.1 + id: create_tag + with: + commit_sha: ${{ steps.auto_commit.outputs.commit_hash }} + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: ${{ steps.get_new_version.outputs.new_version }} + + - name: Build + run: npm run build + - name: Release to npm run: npm publish --access public env: