From 9499f538c458f4ff04fdc395a015a8238cfc91a3 Mon Sep 17 00:00:00 2001 From: mintaka Date: Tue, 10 Nov 2026 23:45:40 -0500 Subject: [PATCH 1/5] ci(release): publish nix2container binaries on release tags (RIG-9273) Build linux-amd64, linux-arm64 and darwin-arm64 binaries with CGO disabled, then attach them and SHA256SUMS to a GitHub Release. The release job runs only on v*-rigel.N tags minted by release-tag.yaml, and checks the tag against .github/rigel-version. Pull requests run the build matrix only. Add an hk pre-push hook so rjc's hook gate sees a configured check. Co-authored-by: Matt Wilkinson --- .github/workflows/release.yml | 66 +++++++++++++++++++++++++++++++++++ hk.pkl | 15 ++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 hk.pkl diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ed62f4a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,66 @@ +name: release + +# A v*-rigel.N tag, minted by release-tag.yaml, publishes the nix2container binaries. +# Pull requests run only the build matrix, so a broken cross-compile fails before a tag exists. +on: + pull_request: + push: + tags: + - 'v*-rigel.*' + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - { goos: linux, goarch: amd64 } + - { goos: linux, goarch: arm64 } + - { goos: darwin, goarch: arm64 } + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: go.mod + - name: Build binary + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: "0" + run: | + out="nix2container_v$(cat .github/rigel-version)_${GOOS}_${GOARCH}" + go build -trimpath -ldflags '-s -w' -o "$out" . + sha256sum "$out" > "$out.sha256" + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: bin-${{ matrix.goos }}-${{ matrix.goarch }} + path: nix2container_* + + release: + needs: build + if: github.event_name == 'push' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - name: Require the tag to name the version file + env: + RELEASE_TAG: ${{ github.ref_name }} + run: test "$RELEASE_TAG" = "v$(cat .github/rigel-version)" + - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 + with: + path: dist + merge-multiple: true + - name: Aggregate SHA256SUMS + run: cd dist && cat ./*.sha256 > SHA256SUMS && rm -f ./*.sha256 + - uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 + with: + tag_name: ${{ github.ref_name }} + files: | + dist/nix2container_* + dist/SHA256SUMS + fail_on_unmatched_files: true diff --git a/hk.pkl b/hk.pkl new file mode 100644 index 0000000..71c086f --- /dev/null +++ b/hk.pkl @@ -0,0 +1,15 @@ +// Git hooks managed by hk (https://hk.jdx.dev). +amends "package://github.com/jdx/hk/releases/download/v2.11.1/hk@2.11.1#/Config.pkl" + +default_branch = "rigel-release" + +hooks { + ["pre-push"] { + steps { + ["release-workflow-yaml"] = new Step { + glob = List(".github/workflows/release.yml") + check = "yq -e '.jobs | keys' {{files}} >/dev/null" + } + } + } +} From ba7b7b227c6c36235753b1a92e1272963e9ae7f7 Mon Sep 17 00:00:00 2001 From: mintaka Date: Wed, 11 Nov 2026 00:30:03 -0500 Subject: [PATCH 2/5] ci(lint): pin golangci-lint to v2.15.0 (RIG-9273) The lint job used golangci-lint-action@v3 with version latest. That resolved to v1.64.8, built with Go 1.24, and failed on the Go 1.26 runner with 'file requires newer Go version go1.26'. Pin the action to v9.3.0 by SHA and the linter to v2.15.0, the newest v2 release whose go.mod targets Go 1.26. The -E gofmt arg still resolves under v2. Co-authored-by: Matt Wilkinson --- .github/workflows/golangci-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b121fa2..8649c9c 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-go@v3 - uses: actions/checkout@v3 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: - version: latest + version: v2.15.0 args: -E gofmt From 6021c6110c8d1005eb7144133786e5476ab52a76 Mon Sep 17 00:00:00 2001 From: mintaka Date: Wed, 11 Nov 2026 00:33:38 -0500 Subject: [PATCH 3/5] ci(lint): enable gofmt as a v2 formatter (RIG-9273) golangci-lint v2 rejects '-E gofmt' with 'gofmt is a formatter', so the lint job failed at config load even on the pinned v2.15.0 binary. Move the gofmt check into a version 2 .golangci.yml, pin the linter set to standard to match the v1 default, and drop the args line. Co-authored-by: Matt Wilkinson --- .github/workflows/golangci-lint.yml | 1 - .golangci.yml | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .golangci.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 8649c9c..edd69f6 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,4 +21,3 @@ jobs: uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: version: v2.15.0 - args: -E gofmt diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..c905335 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,8 @@ +version: "2" + +linters: + default: standard + +formatters: + enable: + - gofmt From 1e0a47d4d12841889039055a0fa58b4fdffbd591 Mon Sep 17 00:00:00 2001 From: mintaka Date: Wed, 11 Nov 2026 00:52:44 -0500 Subject: [PATCH 4/5] ci(release): harden release workflow and lint checks (RIG-9273) - Build release binaries with Go 1.26.11 via setup-go go-version, not the go.mod floor (go 1.24.0), so binaries carry a current stdlib. - Add workflow_dispatch with an existing tag input to backfill a release. - Move the tag/version guard into a guard job the build depends on, so a mismatched tag fails before the matrix runs. - Add a concurrency group so a manual re-run cannot race a first run. - Pin checkout and setup-go in the lint job to the release SHAs and read the Go version from go.mod. - Replace the yq parse check in the pre-push hook with actionlint, and add actionlint to the devShell. Co-authored-by: Matt Wilkinson --- .github/workflows/golangci-lint.yml | 6 +++-- .github/workflows/release.yml | 37 +++++++++++++++++++++++++---- flake.nix | 2 +- hk.pkl | 6 ++--- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index edd69f6..274538b 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -15,8 +15,10 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 - - uses: actions/checkout@v3 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 + with: + go-version-file: go.mod - name: golangci-lint uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ed62f4a..c9e6b62 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,18 +1,42 @@ name: release # A v*-rigel.N tag, minted by release-tag.yaml, publishes the nix2container binaries. +# workflow_dispatch backfills an existing tag: pass it as the tag input. # Pull requests run only the build matrix, so a broken cross-compile fails before a tag exists. on: pull_request: push: tags: - 'v*-rigel.*' + workflow_dispatch: + inputs: + tag: + description: 'Existing tag to publish, e.g. v1.1.0-rigel.1' + required: true + type: string permissions: contents: read +concurrency: + group: release-${{ github.ref }}-${{ inputs.tag }} + cancel-in-progress: false + jobs: + guard: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + ref: ${{ inputs.tag || github.ref }} + - name: Require the tag to name the version file + if: github.event_name != 'pull_request' + env: + RELEASE_TAG: ${{ inputs.tag || github.ref_name }} + run: test "$RELEASE_TAG" = "v$(cat .github/rigel-version)" + build: + needs: guard runs-on: ubuntu-latest strategy: matrix: @@ -22,9 +46,12 @@ jobs: - { goos: darwin, goarch: arm64 } steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + ref: ${{ inputs.tag || github.ref }} - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 with: - go-version-file: go.mod + # Release binaries use a current patch release, not the go.mod language floor. + go-version: '1.26.11' - name: Build binary env: GOOS: ${{ matrix.goos }} @@ -41,15 +68,17 @@ jobs: release: needs: build - if: github.event_name == 'push' + if: github.event_name != 'pull_request' runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + ref: ${{ inputs.tag || github.ref }} - name: Require the tag to name the version file env: - RELEASE_TAG: ${{ github.ref_name }} + RELEASE_TAG: ${{ inputs.tag || github.ref_name }} run: test "$RELEASE_TAG" = "v$(cat .github/rigel-version)" - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: @@ -59,7 +88,7 @@ jobs: run: cd dist && cat ./*.sha256 > SHA256SUMS && rm -f ./*.sha256 - uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 with: - tag_name: ${{ github.ref_name }} + tag_name: ${{ inputs.tag || github.ref_name }} files: | dist/nix2container_* dist/SHA256SUMS diff --git a/flake.nix b/flake.nix index 24f0b4f..f6019f7 100644 --- a/flake.nix +++ b/flake.nix @@ -40,7 +40,7 @@ default = pkgs.mkShell { buildInputs = [ pkgs.go pkgs.godef pkgs.gopls - pkgs.golangci-lint + pkgs.golangci-lint pkgs.actionlint ]; }; } diff --git a/hk.pkl b/hk.pkl index 71c086f..f5f274a 100644 --- a/hk.pkl +++ b/hk.pkl @@ -6,9 +6,9 @@ default_branch = "rigel-release" hooks { ["pre-push"] { steps { - ["release-workflow-yaml"] = new Step { - glob = List(".github/workflows/release.yml") - check = "yq -e '.jobs | keys' {{files}} >/dev/null" + ["workflow-lint"] = new Step { + glob = List(".github/workflows/release.yml", ".github/workflows/golangci-lint.yml") + check = "actionlint {{files}}" } } } From 2a27ddbde29ef11202d9721e40ad9149451d9098 Mon Sep 17 00:00:00 2001 From: mintaka Date: Wed, 11 Nov 2026 01:03:42 -0500 Subject: [PATCH 5/5] ci(release): key concurrency on tag and resolve dispatch to refs/tags (RIG-9273) - Key concurrency on the release tag so a dispatch backfill and a tag push for the same tag serialize. - Check out refs/tags/ on dispatch, so a non-tag input fails at checkout rather than creating a release at another branch's SHA. - Use go-version 1.26 with check-latest, so the release toolchain picks up patch releases without a manual bump. Co-authored-by: Matt Wilkinson --- .github/workflows/release.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c9e6b62..1ddfafb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ permissions: contents: read concurrency: - group: release-${{ github.ref }}-${{ inputs.tag }} + group: release-${{ inputs.tag || github.ref_name }} cancel-in-progress: false jobs: @@ -28,7 +28,7 @@ jobs: steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: - ref: ${{ inputs.tag || github.ref }} + ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }} - name: Require the tag to name the version file if: github.event_name != 'pull_request' env: @@ -47,11 +47,12 @@ jobs: steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: - ref: ${{ inputs.tag || github.ref }} + ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }} - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 with: - # Release binaries use a current patch release, not the go.mod language floor. - go-version: '1.26.11' + # Release binaries use a current 1.26 patch release, not the go.mod language floor. + go-version: '1.26' + check-latest: true - name: Build binary env: GOOS: ${{ matrix.goos }} @@ -75,7 +76,7 @@ jobs: steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 with: - ref: ${{ inputs.tag || github.ref }} + ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || github.ref }} - name: Require the tag to name the version file env: RELEASE_TAG: ${{ inputs.tag || github.ref_name }}