From 03be729190a037c2248ba4b269e9253277cdba04 Mon Sep 17 00:00:00 2001 From: Jackie Weng Date: Thu, 26 Jun 2025 12:47:58 +1200 Subject: [PATCH 1/8] test: added test job to run the action --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44f4f2a..0849b45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,3 +21,26 @@ jobs: git config --global user.email "test@test.com" git config --global user.name "test" make test + + action-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ github.head_ref }} # checkout the correct branch name + fetch-depth: 0 # fetch the whole repo history + + - id: version + uses: ./ + with: + skip-prerelease: true + major-identifier: "BREAKING CHANGE:" + minor-identifier: "feat:" + prefix: "v" + + - name: New version + run: | + echo ${{ steps.version.outputs.version }} + - name: Previous version + run: | + echo ${{ steps.version.outputs.previous-version }} From 6e2e49416758093c799b31e794b9fcebd120d936 Mon Sep 17 00:00:00 2001 From: Jackie Weng Date: Thu, 26 Jun 2025 12:53:17 +1200 Subject: [PATCH 2/8] chore: added logging --- action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 14bd3bc..d4fc9a0 100644 --- a/action.yml +++ b/action.yml @@ -53,11 +53,12 @@ runs: run: | set -eo pipefail if [ "${{ inputs.tool-version }}" = "latest" ]; then - download_url="$(curl -Ls https://api.github.com/repos/linz/action-git-version/releases/latest | jq -r .assets[0].browser_download_url)" + download_url="$(curl -L https://api.github.com/repos/linz/action-git-version/releases/latest | jq -r .assets[0].browser_download_url)" else download_url="https://github.com/linz/action-git-version/releases/download/${{ inputs.tool-version }}/git-version" fi - sudo curl -Ls "$download_url" -o /usr/local/bin/git-version + echo "Downloading git-version from $download_url" + sudo curl -L "$download_url" -o /usr/local/bin/git-version sudo chmod +x /usr/local/bin/git-version - id: previous-version shell: bash From e64e5351e9d67b59fb49e9f5b457611d5d99e498 Mon Sep 17 00:00:00 2001 From: Jackie Weng Date: Thu, 26 Jun 2025 12:55:14 +1200 Subject: [PATCH 3/8] fix: retry curl failures --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index d4fc9a0..5ea7421 100644 --- a/action.yml +++ b/action.yml @@ -53,12 +53,12 @@ runs: run: | set -eo pipefail if [ "${{ inputs.tool-version }}" = "latest" ]; then - download_url="$(curl -L https://api.github.com/repos/linz/action-git-version/releases/latest | jq -r .assets[0].browser_download_url)" + download_url="$(curl --retry 3 -L https://api.github.com/repos/linz/action-git-version/releases/latest | jq -r .assets[0].browser_download_url)" else download_url="https://github.com/linz/action-git-version/releases/download/${{ inputs.tool-version }}/git-version" fi echo "Downloading git-version from $download_url" - sudo curl -L "$download_url" -o /usr/local/bin/git-version + sudo curl --retry 3 -L "$download_url" -o /usr/local/bin/git-version sudo chmod +x /usr/local/bin/git-version - id: previous-version shell: bash From 0ec03d845253f497a4361c320ff94399f683df97 Mon Sep 17 00:00:00 2001 From: Jackie Weng Date: Thu, 26 Jun 2025 13:07:45 +1200 Subject: [PATCH 4/8] fix: use Github CLI to download binary to avoid rate limit --- action.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 5ea7421..601c6a0 100644 --- a/action.yml +++ b/action.yml @@ -52,13 +52,11 @@ runs: - shell: bash run: | set -eo pipefail - if [ "${{ inputs.tool-version }}" = "latest" ]; then - download_url="$(curl --retry 3 -L https://api.github.com/repos/linz/action-git-version/releases/latest | jq -r .assets[0].browser_download_url)" - else - download_url="https://github.com/linz/action-git-version/releases/download/${{ inputs.tool-version }}/git-version" + TAG_OPT="" + if [ "${{ inputs.tool-version }}" != "latest" ]; then + TAG_OPT="${{ inputs.tool-version }}" fi - echo "Downloading git-version from $download_url" - sudo curl --retry 3 -L "$download_url" -o /usr/local/bin/git-version + sudo gh release download $TAG_OPT --repo linz/action-git-version --pattern git-version --dir /usr/local/bin/ --clobber sudo chmod +x /usr/local/bin/git-version - id: previous-version shell: bash From 12a0fb81a4fbce901c5ddffac71d284773bb0823 Mon Sep 17 00:00:00 2001 From: Jackie Weng Date: Thu, 26 Jun 2025 13:09:18 +1200 Subject: [PATCH 5/8] fix: set GH_TOKEN --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index 601c6a0..c1a1cb5 100644 --- a/action.yml +++ b/action.yml @@ -50,6 +50,8 @@ runs: using: "composite" steps: - shell: bash + env: + GH_TOKEN: ${{ github.token }} run: | set -eo pipefail TAG_OPT="" @@ -58,6 +60,7 @@ runs: fi sudo gh release download $TAG_OPT --repo linz/action-git-version --pattern git-version --dir /usr/local/bin/ --clobber sudo chmod +x /usr/local/bin/git-version + - id: previous-version shell: bash run: | From 5d5db24f714aa11cf148561e98146863babf4e7b Mon Sep 17 00:00:00 2001 From: Jackie Weng Date: Thu, 26 Jun 2025 13:21:18 +1200 Subject: [PATCH 6/8] use github cli only to work out latest release --- action.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index c1a1cb5..c420c6a 100644 --- a/action.yml +++ b/action.yml @@ -52,13 +52,17 @@ runs: - shell: bash env: GH_TOKEN: ${{ github.token }} + TOOL_VERSION: ${{ inputs.tool-version }} run: | set -eo pipefail - TAG_OPT="" - if [ "${{ inputs.tool-version }}" != "latest" ]; then - TAG_OPT="${{ inputs.tool-version }}" + if [ "$TOOL_VERSION" = "latest" ]; then + download_url="$(gh release view --repo linz/action-git-version --json assets | jq -r .assets[0].url)" + else + download_url="https://github.com/linz/action-git-version/releases/download/$TOOL_VERSION/git-version" fi - sudo gh release download $TAG_OPT --repo linz/action-git-version --pattern git-version --dir /usr/local/bin/ --clobber + + echo "Downloading git-version from $download_url" + sudo curl --retry 3 -L "$download_url" -o /usr/local/bin/git-version sudo chmod +x /usr/local/bin/git-version - id: previous-version From 46b21a7b9339bbc199e934c2b126beb0c6da0a4f Mon Sep 17 00:00:00 2001 From: Jackie Weng Date: Thu, 26 Jun 2025 13:30:39 +1200 Subject: [PATCH 7/8] test: run action 20 times to check for rate limit --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0849b45..257fe6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,27 @@ jobs: ref: ${{ github.head_ref }} # checkout the correct branch name fetch-depth: 0 # fetch the whole repo history + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - uses: ./ + - id: version uses: ./ with: From e8a36d0b7b24f651efd5517254b0301db9ffe86b Mon Sep 17 00:00:00 2001 From: Jackie Weng Date: Thu, 26 Jun 2025 13:35:53 +1200 Subject: [PATCH 8/8] remove 20 time run --- .github/workflows/ci.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 257fe6b..0849b45 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,27 +30,6 @@ jobs: ref: ${{ github.head_ref }} # checkout the correct branch name fetch-depth: 0 # fetch the whole repo history - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - uses: ./ - - id: version uses: ./ with: