name: Release on: push: tags: - '[0-9]*.[0-9]*.[0-9]*' concurrency: group: release cancel-in-progress: false permissions: contents: write actions: read id-token: write attestations: write jobs: ci-preflight: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - name: Require latest main checks success env: GH_TOKEN: ${{ github.token }} run: ./scripts/release-require-green-main.sh live-evaluations: uses: ./.github/workflows/eval-live.yml secrets: inherit debian-amd64: needs: [ci-preflight, live-evaluations] runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 with: fetch-depth: 0 - uses: actions/setup-go@v6 with: go-version-file: go.mod - name: Install Debian tooling env: DEBIAN_FRONTEND: noninteractive run: sudo apt-get update && sudo apt-get install -y debhelper dpkg-dev lintian bash-completion pandoc - name: Configure git and dch environment run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" echo 'DEBFULLNAME=Brian Cosgrove' >> "$GITHUB_ENV" echo 'DEBEMAIL=cosgroveb@gmail.com' >> "$GITHUB_ENV" - name: Merge main into debian/main run: | git checkout debian/main git merge --no-edit "${{ github.sha }}" - name: Generate changelog run: | VERSION="${GITHUB_REF_NAME}" DATE="$(date -R)" cat > debian/changelog < ${DATE} EOF - name: Generate orig tarball run: | VERSION="${GITHUB_REF_NAME}" git archive --format=tar.gz --prefix="clnkr-${VERSION}/" \ HEAD -- . ':(exclude)debian' > "../clnkr_${VERSION}.orig.tar.gz" - name: Build amd64 package # -d skips Build-Depends check: golang-go comes from actions/setup-go, not apt run: dpkg-buildpackage -us -uc -d - name: Run lintian run: | lintian --profile debian \ --suppress-tags latest-debian-changelog-entry-reuses-existing-version \ --fail-on error ../*.changes - name: Collect build output run: | cp ../clnkr_*.deb . cp debian/changelog debian-changelog - name: Upload deb uses: actions/upload-artifact@v4 with: name: deb-amd64 path: clnkr_*.deb - name: Upload changelog uses: actions/upload-artifact@v4 with: name: debian-changelog path: debian-changelog debian-arm64: needs: [ci-preflight, live-evaluations] runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v5 with: fetch-depth: 0 - uses: actions/setup-go@v6 with: go-version-file: go.mod - name: Install Debian tooling env: DEBIAN_FRONTEND: noninteractive run: sudo apt-get update && sudo apt-get install -y debhelper dpkg-dev lintian bash-completion pandoc - name: Configure git and dch environment run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" echo 'DEBFULLNAME=Brian Cosgrove' >> "$GITHUB_ENV" echo 'DEBEMAIL=cosgroveb@gmail.com' >> "$GITHUB_ENV" - name: Merge main into debian/main run: | git checkout debian/main git merge --no-edit "${{ github.sha }}" - name: Generate changelog run: | VERSION="${GITHUB_REF_NAME}" DATE="$(date -R)" cat > debian/changelog < ${DATE} EOF - name: Generate orig tarball run: | VERSION="${GITHUB_REF_NAME}" git archive --format=tar.gz --prefix="clnkr-${VERSION}/" \ HEAD -- . ':(exclude)debian' > "../clnkr_${VERSION}.orig.tar.gz" - name: Build arm64 package # -d skips Build-Depends check: golang-go comes from actions/setup-go, not apt run: dpkg-buildpackage -us -uc -d - name: Run lintian run: | lintian --profile debian \ --suppress-tags latest-debian-changelog-entry-reuses-existing-version \ --fail-on error ../*.changes - name: Collect build output run: cp ../clnkr_*.deb . - name: Upload deb uses: actions/upload-artifact@v4 with: name: deb-arm64 path: clnkr_*.deb binaries: needs: [ci-preflight, live-evaluations] runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-go@v6 with: go-version-file: go.mod - name: Test run: go test -race ./... - name: Cross-compile binaries run: | VERSION="${GITHUB_REF_NAME}" for GOOS in linux darwin; do for GOARCH in amd64 arm64; do for CMD in clnkr clnkrd; do env CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ go build -trimpath -ldflags "-s -w -X main.version=${VERSION}" \ -o "${CMD}-${GOOS}-${GOARCH}" "./cmd/${CMD}/" done done done - name: Upload binaries uses: actions/upload-artifact@v4 with: name: binaries path: | clnkr-* clnkrd-* release: needs: [debian-amd64, debian-arm64, binaries] runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 with: fetch-depth: 0 - name: Install dpkg-dev run: sudo apt-get update && sudo apt-get install -y dpkg-dev - name: Configure git run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - name: Download all artifacts uses: actions/download-artifact@v4 with: path: artifacts - name: Push debian/main run: | VERSION="${GITHUB_REF_NAME}" git checkout debian/main git merge --no-edit "${{ github.sha }}" cp artifacts/debian-changelog/debian-changelog debian/changelog git add debian/changelog git commit --allow-empty -m "Update changelog for ${VERSION}-1" git push origin debian/main - name: Generate CHANGELOG.md run: | git checkout main VERSION="${GITHUB_REF_NAME}" DATE=$(git log -1 --format=%cs "$GITHUB_REF_NAME") { echo "# Changelog" echo "" echo "## ${VERSION} (${DATE})" echo "" echo "- Restart release history for the clnkr CLI." echo "" } > CHANGELOG.md git add CHANGELOG.md git diff --cached --quiet || { git commit -m "Update CHANGELOG.md for ${GITHUB_REF_NAME}" git push origin main } - name: Collect assets run: | mkdir -p release cp artifacts/deb-amd64/*.deb release/ cp artifacts/deb-arm64/*.deb release/ cp artifacts/binaries/clnkr-* artifacts/binaries/clnkrd-* release/ - name: Generate source tarball run: | VERSION="${GITHUB_REF_NAME}" git archive --format=tar.gz --prefix="clnkr-${VERSION}/" \ -o "release/clnkr_${VERSION}.orig.tar.gz" "${{ github.sha }}" - name: Generate checksums run: | cd release sha256sum ./* > SHA256SUMS - name: Attest release artifacts uses: actions/attest-build-provenance@v2 with: subject-path: release/* - name: Extract release notes run: | dpkg-parsechangelog -l artifacts/debian-changelog/debian-changelog \ --show-field Changes > release-notes.txt - name: Create GitHub release env: GH_TOKEN: ${{ github.token }} run: | VERSION="${GITHUB_REF_NAME}" # Delete any existing release from a failed run gh release delete "${GITHUB_REF_NAME}" --yes 2>/dev/null || true gh release create "${GITHUB_REF_NAME}" \ --title "clnkr ${VERSION}" \ --notes-file release-notes.txt \ release/* - name: Update Homebrew tap env: GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} run: | VERSION="${GITHUB_REF_NAME}" SHA=$(curl -sL "https://github.com/clnkr-ai/clnkr/archive/refs/tags/${VERSION}.tar.gz" | sha256sum | awk '{print $1}') git clone "https://x-access-token:${GH_TOKEN}@github.com/clnkr-ai/homebrew-tap.git" /tmp/tap cd /tmp/tap sed -i "s|url \".*\"|url \"https://github.com/clnkr-ai/clnkr/archive/refs/tags/${VERSION}.tar.gz\"|" Formula/clnkr.rb sed -i "s|sha256 \".*\"|sha256 \"${SHA}\"|" Formula/clnkr.rb git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add Formula/clnkr.rb git diff --cached --quiet || { git commit -m "Update clnkr to ${VERSION}" git push }