From c825f0f689ef82e20e02798ded432558368e1730 Mon Sep 17 00:00:00 2001 From: James Greenhill Date: Thu, 8 Aug 2024 12:42:04 -0700 Subject: [PATCH 1/2] fixes: more fixes for the auto version bumper --- .github/workflows/bump-version.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index ca502b3..8d7e4ae 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -24,7 +24,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }} run: | - if [[ $(gh pr view ${{ github.event.pull_request.number }} --json labels -q '.labels[].name' | grep -q "minor") ]]; then + pr_number=$(gh pr list --base master --state merged --limit 1 --json number --jq '.[0].number') + if [[ $(gh pr view $pr_number --json labels -q '.labels[].name' | grep -q "minor") ]]; then echo "type=minor" >> $GITHUB_OUTPUT else echo "type=patch" >> $GITHUB_OUTPUT From b0a7860fa848e0e6466c361e94dfc3158a0070a8 Mon Sep 17 00:00:00 2001 From: James Greenhill Date: Thu, 8 Aug 2024 15:05:06 -0700 Subject: [PATCH 2/2] fix: set persist-credential to false and provide PAT --- .github/workflows/bump-version.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 8d7e4ae..d5454d2 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - token: ${{ secrets.POSTHOG_BOT_GITHUB_TOKEN }} + persist-credential: false - name: Set up Go uses: actions/setup-go@v3 @@ -57,12 +57,14 @@ jobs: echo -e "## $new_version\n\n* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v${current_version}...v${new_version})\n\n$(cat CHANGELOG.md)" > CHANGELOG.md - name: Commit and push changes + env: + PAT: ${{ secrets.PAT_WITH_PUSH_ACCESS }} run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add version.go CHANGELOG.md git commit -m "Bump version to ${{ steps.bump-version.outputs.new_version }}" - git push + git push https://$PAT@github.com/${{ github.repository }}.git HEAD:master - name: Create tag run: |