Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,49 @@ outputs:
runs:
using: 'composite'
steps:
# github.action_ref is empty inside a composite action's run steps (and
# leaks the ref of `uses:` steps like actions/cache), so we resolve the
# release repo/tag ourselves.
#
# When the action is consumed remotely (uses: owner/repo@ref) github.action_path
# is .../_actions/<owner>/<repo>/<ref>, so both repo and version come from it.
# When it is used locally (uses: ./) github.action_path is just the checked-out
# repo directory, so we fall back to the caller repo plus the checked-out tag
# (github.ref_name is the workflow trigger ref, which is not the tag for
# release-testing jobs, so prefer the exact tag git actually checked out).
- name: Resolve action repo and version
id: meta
shell: bash
run: |
AP="${{ github.action_path }}"
if [[ "$AP" == *"/_actions/"* ]]; then
REST="${AP#*/_actions/}"
OWNER="${REST%%/*}"; REST="${REST#*/}"
NAME="${REST%%/*}"; REF="${REST#*/}"
REPO="${OWNER}/${NAME}"
VERSION="${REF}"
else
REPO="${{ github.repository }}"
VERSION="$(git -C "$AP" describe --tags --exact-match 2>/dev/null || echo "${{ github.ref_name }}")"
fi
echo "repo=${REPO}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

- name: Restore cached binary
id: cache
uses: actions/cache@v4
with:
path: /tmp/cac
key: cac-${{ runner.os }}-${{ runner.arch }}-${{ github.action_ref || github.ref_name }}
key: cac-${{ runner.os }}-${{ runner.arch }}-${{ steps.meta.outputs.version }}

- name: Download pre-built binary
id: download
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
continue-on-error: true
run: |
VERSION="${{ github.action_ref || github.ref_name }}"
REPO="${{ github.action_repository }}"
VERSION="${{ steps.meta.outputs.version }}"
REPO="${{ steps.meta.outputs.repo }}"

ARCH=$(uname -m)
case "$ARCH" in
Expand Down
Loading