From f4c305cf7d69ae6eccd971bb8397decbba0cb42a Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Sun, 8 Dec 2024 22:28:51 -0500 Subject: [PATCH 1/5] chore: fix `create-tag` conditional logic --- .github/workflows/create-tag.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index d35082f253..acb6419219 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -13,11 +13,11 @@ on: jobs: create-tag: if: >- - (inputs.commit || false) && - github.event.pull_request.merged == true && - github.event.pull_request.user.login == 'github-actions' && - github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && - startsWith(github.event.pull_request.head.ref, 'bump-version') + (inputs.commit || false) || + (github.event.pull_request.merged == true && + github.event.pull_request.user.login == 'github-actions' && + github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name && + startsWith(github.event.pull_request.head.ref, 'bump-version') ) runs-on: ubuntu-latest steps: - name: Checkout code From 902208210de361910d6a9d1a72139e83a90e062b Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Sun, 8 Dec 2024 22:35:30 -0500 Subject: [PATCH 2/5] ci: fix `git rev-parse` --- .github/workflows/create-tag.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index acb6419219..0ec4fc8e6c 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -28,7 +28,7 @@ jobs: if [[ -z "${{ inputs.commit }}" ]]; then COMMIT="${{ inputs.commit }}" else - COMMIT=git rev-parse ${{ github.sha }}^@ | grep -Fvx ${{ github.event.pull_request.head.sha }} + COMMIT=$(git rev-parse ${{ github.sha }}^@ | grep -Fvx ${{ github.event.pull_request.head.sha }}) fi git checkout $COMMIT From 7e640a99c48f936f652bf61e5575ced2791c3a6a Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Sun, 8 Dec 2024 22:39:46 -0500 Subject: [PATCH 3/5] ci: invert conditional --- .github/workflows/create-tag.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 0ec4fc8e6c..02760909bd 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -26,9 +26,9 @@ jobs: - name: Checkout to the input commit run: | if [[ -z "${{ inputs.commit }}" ]]; then - COMMIT="${{ inputs.commit }}" - else COMMIT=$(git rev-parse ${{ github.sha }}^@ | grep -Fvx ${{ github.event.pull_request.head.sha }}) + else + COMMIT="${{ inputs.commit }}" fi git checkout $COMMIT From e2144bf355e4b2aaa7b25a73d7f71a9b60b39d0d Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Sun, 8 Dec 2024 22:47:28 -0500 Subject: [PATCH 4/5] ci: fetch all the history --- .github/workflows/create-tag.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 02760909bd..8f47f2d830 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -22,6 +22,8 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Checkout to the input commit run: | From 7d4daffcc1abe9f8920a37753d53b87718f17aca Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Sun, 8 Dec 2024 23:21:11 -0500 Subject: [PATCH 5/5] chore: use custom action to create the tag --- .github/workflows/create-tag.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml index 8f47f2d830..f636991c38 100644 --- a/.github/workflows/create-tag.yml +++ b/.github/workflows/create-tag.yml @@ -25,14 +25,14 @@ jobs: with: fetch-depth: 0 - - name: Checkout to the input commit + - name: Compute the commit run: | if [[ -z "${{ inputs.commit }}" ]]; then COMMIT=$(git rev-parse ${{ github.sha }}^@ | grep -Fvx ${{ github.event.pull_request.head.sha }}) else COMMIT="${{ inputs.commit }}" fi - git checkout $COMMIT + echo "commit=$COMMIT" >> $GITHUB_ENV - name: Install rust toolchain uses: dtolnay/rust-toolchain@stable @@ -42,7 +42,8 @@ jobs: echo "version=$(cargo pkgid -p bindgen | cut -d '#' -f 2)" >> $GITHUB_ENV - name: Create tag - run: | - TAG_NAME="v${{ env.version }}" - git tag -s $TAG_NAME - git push origin $TAG_NAME + uses: mathieudutour/github-tag-action@v6.2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + commit_sha: ${{ env.commit }} + custom_tag: ${{ env.version }}