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 }} diff --git a/action.yml b/action.yml index 14bd3bc..c420c6a 100644 --- a/action.yml +++ b/action.yml @@ -50,15 +50,21 @@ runs: using: "composite" steps: - shell: bash + env: + GH_TOKEN: ${{ github.token }} + TOOL_VERSION: ${{ inputs.tool-version }} 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)" + 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/${{ inputs.tool-version }}/git-version" + download_url="https://github.com/linz/action-git-version/releases/download/$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 --retry 3 -L "$download_url" -o /usr/local/bin/git-version sudo chmod +x /usr/local/bin/git-version + - id: previous-version shell: bash run: |