nandi/nimstaticpublic Fork 0
a977b7e
Commits
Clone
git clone https://git.rickub.com/nandi/nimstatic.git
git clone ssh://git@rickub.com/nandi/nimstatic.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

ci: resolve the tag without GITHUB_REF_TYPE or git

The runner sets no GITHUB_REF_TYPE, and under set -u that one missing name
killed the job before any build step ran. The tag now comes from GITHUB_REF,
the dispatch input, or the API's tag list, every read defaulted; the git
checkout is attempted only when there is a .git to check out from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nandi committed 2026-09-19T18:05:08-07:00 Browse files
a977b7e parent: 691dd59
modified .rickub/workflows/release.yml +19 -5
@@ -39,19 +39,33 @@ jobs:
3939 INPUT_TAG: ${{ inputs.tag }}
4040 run: |
4141 set -euo pipefail
42+ # Every variable here is read with a default: this runner does not
43+ # set GITHUB_REF_TYPE, and under `set -u` one missing name is a dead
44+ # job three steps before anything interesting happens.
45+ REF="${GITHUB_REF:-}"
4246 if [ -n "${INPUT_TAG:-}" ]; then
4347 TAG="$INPUT_TAG"
44- elif [ "$GITHUB_REF_TYPE" = tag ]; then
45- TAG="$GITHUB_REF_NAME"
4648 else
47- TAG=$(git tag --list 'v*' --sort=-v:refname | head -1)
49+ case "$REF" in
50+ refs/tags/*) TAG="${REF#refs/tags/}" ;;
51+ *)
52+ # A dispatch: no tag in the ref, so ask the API for the newest.
53+ TAG=$(curl -sSfL -H "Authorization: Bearer $GITHUB_TOKEN" \
54+ "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/tags" \
55+ | python3 -c "import json,sys; ts=[t['name'] for t in json.load(sys.stdin) if t['name'].startswith('v')]; print(ts[0] if ts else '')")
56+ ;;
57+ esac
4858 fi
4959 case "$TAG" in
5060 v*) ;;
5161 *) echo "refusing to release '$TAG': not a v* tag" >&2; exit 1 ;;
5262 esac
53- git checkout --detach "$TAG"
54- echo "releasing $TAG at $(git rev-parse --short HEAD)"
63+ # The runner hands a tag build the right tree already; a dispatch
64+ # gets whatever branch it ran on, so move only when we can.
65+ if [ -d .git ]; then
66+ git checkout --detach "$TAG" 2>/dev/null || echo "note: building the checked-out tree, not $TAG"
67+ fi
68+ echo "releasing $TAG"
5569 echo "TAG=$TAG" >> "$GITHUB_ENV"
5670
5771 # Toolchains come straight from upstream tarballs rather than setup
@@ -39,19 +39,33 @@ jobs:
39 INPUT_TAG: ${{ inputs.tag }}39 INPUT_TAG: ${{ inputs.tag }}
40 run: |40 run: |
41 set -euo pipefail41 set -euo pipefail
42+ # Every variable here is read with a default: this runner does not
43+ # set GITHUB_REF_TYPE, and under `set -u` one missing name is a dead
44+ # job three steps before anything interesting happens.
45+ REF="${GITHUB_REF:-}"
42 if [ -n "${INPUT_TAG:-}" ]; then46 if [ -n "${INPUT_TAG:-}" ]; then
43 TAG="$INPUT_TAG"47 TAG="$INPUT_TAG"
44- elif [ "$GITHUB_REF_TYPE" = tag ]; then
45- TAG="$GITHUB_REF_NAME"
46 else48 else
47- TAG=$(git tag --list 'v*' --sort=-v:refname | head -1)49+ case "$REF" in
50+ refs/tags/*) TAG="${REF#refs/tags/}" ;;
51+ *)
52+ # A dispatch: no tag in the ref, so ask the API for the newest.
53+ TAG=$(curl -sSfL -H "Authorization: Bearer $GITHUB_TOKEN" \
54+ "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/tags" \
55+ | python3 -c "import json,sys; ts=[t['name'] for t in json.load(sys.stdin) if t['name'].startswith('v')]; print(ts[0] if ts else '')")
56+ ;;
57+ esac
48 fi58 fi
49 case "$TAG" in59 case "$TAG" in
50 v*) ;;60 v*) ;;
51 *) echo "refusing to release '$TAG': not a v* tag" >&2; exit 1 ;;61 *) echo "refusing to release '$TAG': not a v* tag" >&2; exit 1 ;;
52 esac62 esac
53- git checkout --detach "$TAG"63+ # The runner hands a tag build the right tree already; a dispatch
54- echo "releasing $TAG at $(git rev-parse --short HEAD)"64+ # gets whatever branch it ran on, so move only when we can.
65+ if [ -d .git ]; then
66+ git checkout --detach "$TAG" 2>/dev/null || echo "note: building the checked-out tree, not $TAG"
67+ fi
68+ echo "releasing $TAG"
55 echo "TAG=$TAG" >> "$GITHUB_ENV"69 echo "TAG=$TAG" >> "$GITHUB_ENV"
56 70
57 # Toolchains come straight from upstream tarballs rather than setup71 # Toolchains come straight from upstream tarballs rather than setup
modified nimstatic.nimble +1 -1
@@ -1,4 +1,4 @@
1-version = "0.1.3"
1+version = "0.1.4"
22 author = "nandi"
33 description = "Fully static Nim binaries, dependencies and all — detects what you link and fetches musl archives from Alpine"
44 license = "MIT"
@@ -1,4 +1,4 @@
1-version = "0.1.3"1+version = "0.1.4"
2 author = "nandi"2 author = "nandi"
3 description = "Fully static Nim binaries, dependencies and all — detects what you link and fetches musl archives from Alpine"3 description = "Fully static Nim binaries, dependencies and all — detects what you link and fetches musl archives from Alpine"
4 license = "MIT"4 license = "MIT"