| 1 | name: Release |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | tags: |
| 6 | - "v*" |
| 7 | # tag-release.yml dispatches this because GITHUB_TOKEN tag pushes do not |
| 8 | # start other workflows. |
| 9 | workflow_dispatch: |
| 10 | inputs: |
| 11 | tag: |
| 12 | description: Tag to release (e.g. v3.18.2) |
| 13 | required: true |
| 14 | type: string |
| 15 | |
| 16 | permissions: {} |
| 17 | |
| 18 | jobs: |
| 19 | # Validate release tag syntax, exact git tag resolution, and lockstep |
| 20 | # manifest versions before any job builds artifacts or mints SLSA |
| 21 | # provenance attestations. |
| 22 | validate: |
| 23 | runs-on: ubuntu-latest |
| 24 | permissions: |
| 25 | contents: read |
| 26 | outputs: |
| 27 | tag: ${{ steps.verify.outputs.tag }} |
| 28 | version: ${{ steps.verify.outputs.version }} |
| 29 | commit: ${{ steps.verify.outputs.commit }} |
| 30 | steps: |
| 31 | - name: Validate release tag format |
| 32 | id: format |
| 33 | env: |
| 34 | # Tag push uses ref_name (vX.Y.Z); dispatch from tag-release passes inputs.tag. |
| 35 | RAW_RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} |
| 36 | run: | |
| 37 | set -euo pipefail |
| 38 | if ! [[ "${RAW_RELEASE_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 39 | echo "::error::Invalid release tag format. Expected vMAJOR.MINOR.PATCH (e.g. v4.6.0)." |
| 40 | exit 1 |
| 41 | fi |
| 42 | echo "tag=${RAW_RELEASE_TAG}" >> "${GITHUB_OUTPUT}" |
| 43 | echo "version=${RAW_RELEASE_TAG#v}" >> "${GITHUB_OUTPUT}" |
| 44 | |
| 45 | - name: Checkout tag |
| 46 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 47 | with: |
| 48 | ref: refs/tags/${{ steps.format.outputs.tag }} |
| 49 | fetch-depth: 0 |
| 50 | persist-credentials: false |
| 51 | |
| 52 | - name: Verify tag ref and manifest versions |
| 53 | id: verify |
| 54 | env: |
| 55 | RELEASE_TAG: ${{ steps.format.outputs.tag }} |
| 56 | RELEASE_VERSION: ${{ steps.format.outputs.version }} |
| 57 | run: | |
| 58 | set -euo pipefail |
| 59 | TAG_COMMIT="$(git rev-parse --verify "refs/tags/${RELEASE_TAG}^{commit}")" |
| 60 | HEAD_COMMIT="$(git rev-parse --verify HEAD)" |
| 61 | if [ "${TAG_COMMIT}" != "${HEAD_COMMIT}" ]; then |
| 62 | echo "::error::Checked-out HEAD (${HEAD_COMMIT}) does not match refs/tags/${RELEASE_TAG} (${TAG_COMMIT})." |
| 63 | exit 1 |
| 64 | fi |
| 65 | |
| 66 | PY_VERSION="$(python3 .github/scripts/read_manifest_version.py pyproject.toml < pyproject.toml)" |
| 67 | MCP_VERSION="$(python3 .github/scripts/read_manifest_version.py mcp/manifest.json < mcp/manifest.json)" |
| 68 | if [ "${PY_VERSION}" != "${RELEASE_VERSION}" ]; then |
| 69 | echo "::error::Tag version (${RELEASE_VERSION}) does not match pyproject.toml (${PY_VERSION})." |
| 70 | exit 1 |
| 71 | fi |
| 72 | if [ "${MCP_VERSION}" != "${RELEASE_VERSION}" ]; then |
| 73 | echo "::error::Tag version (${RELEASE_VERSION}) does not match mcp/manifest.json (${MCP_VERSION})." |
| 74 | exit 1 |
| 75 | fi |
| 76 | |
| 77 | echo "tag=${RELEASE_TAG}" >> "${GITHUB_OUTPUT}" |
| 78 | echo "version=${RELEASE_VERSION}" >> "${GITHUB_OUTPUT}" |
| 79 | echo "commit=${TAG_COMMIT}" >> "${GITHUB_OUTPUT}" |
| 80 | |
| 81 | # Build the existing .skill artifact (Claude Code / Codex / Cursor install |
| 82 | # surface). Unchanged from prior versions; just isolated into its own job |
| 83 | # so the .mcpb matrix can run in parallel. |
| 84 | build-skill: |
| 85 | needs: [validate] |
| 86 | runs-on: ubuntu-latest |
| 87 | permissions: |
| 88 | contents: read |
| 89 | id-token: write |
| 90 | attestations: write |
| 91 | steps: |
| 92 | - name: Checkout |
| 93 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 94 | with: |
| 95 | ref: refs/tags/${{ needs.validate.outputs.tag }} |
| 96 | fetch-depth: 0 |
| 97 | persist-credentials: false |
| 98 | |
| 99 | - name: Verify checked-out tag commit |
| 100 | env: |
| 101 | RELEASE_TAG: ${{ needs.validate.outputs.tag }} |
| 102 | EXPECTED_COMMIT: ${{ needs.validate.outputs.commit }} |
| 103 | run: | |
| 104 | set -euo pipefail |
| 105 | TAG_COMMIT="$(git rev-parse --verify "refs/tags/${RELEASE_TAG}^{commit}")" |
| 106 | HEAD_COMMIT="$(git rev-parse --verify HEAD)" |
| 107 | if [ "${TAG_COMMIT}" != "${EXPECTED_COMMIT}" ] || [ "${HEAD_COMMIT}" != "${EXPECTED_COMMIT}" ]; then |
| 108 | echo "::error::Tag ref ${RELEASE_TAG} no longer resolves to validated commit ${EXPECTED_COMMIT}." |
| 109 | exit 1 |
| 110 | fi |
| 111 | |
| 112 | - name: Build .skill artifact |
| 113 | run: | |
| 114 | bash skills/last30days/scripts/build-skill.sh |
| 115 | test -f dist/last30days.skill |
| 116 | |
| 117 | - name: Attest .skill artifact provenance |
| 118 | uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 |
| 119 | with: |
| 120 | subject-path: dist/last30days.skill |
| 121 | |
| 122 | - name: Upload skill artifact |
| 123 | uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 124 | with: |
| 125 | name: last30days-skill |
| 126 | path: dist/last30days.skill |
| 127 | |
| 128 | # Cross-compile the Go MCP server for each Claude Desktop platform and |
| 129 | # package each as a .mcpb. MCPB v0.3 is a ZIP containing the checked-in |
| 130 | # manifest and the pre-built binary at the manifest's entry point. |
| 131 | build-mcpb: |
| 132 | needs: [validate] |
| 133 | runs-on: ubuntu-latest |
| 134 | permissions: |
| 135 | contents: read |
| 136 | id-token: write |
| 137 | attestations: write |
| 138 | env: |
| 139 | MCPB_OUTPUT: mcp/build/last30days-pp-mcp-${{ matrix.goos }}-${{ matrix.goarch }}.mcpb |
| 140 | strategy: |
| 141 | fail-fast: false |
| 142 | matrix: |
| 143 | include: |
| 144 | - goos: darwin |
| 145 | goarch: arm64 |
| 146 | - goos: darwin |
| 147 | goarch: amd64 |
| 148 | - goos: linux |
| 149 | goarch: amd64 |
| 150 | steps: |
| 151 | - name: Checkout |
| 152 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 153 | with: |
| 154 | ref: refs/tags/${{ needs.validate.outputs.tag }} |
| 155 | persist-credentials: false |
| 156 | |
| 157 | - name: Verify checked-out tag commit |
| 158 | env: |
| 159 | EXPECTED_COMMIT: ${{ needs.validate.outputs.commit }} |
| 160 | run: | |
| 161 | set -euo pipefail |
| 162 | HEAD_COMMIT="$(git rev-parse --verify HEAD)" |
| 163 | if [ "${HEAD_COMMIT}" != "${EXPECTED_COMMIT}" ]; then |
| 164 | echo "::error::Checked-out HEAD (${HEAD_COMMIT}) does not match validated commit ${EXPECTED_COMMIT}." |
| 165 | exit 1 |
| 166 | fi |
| 167 | |
| 168 | - name: Set up Go |
| 169 | uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 |
| 170 | with: |
| 171 | # Build the MCP binary with a toolchain newer than the floor in |
| 172 | # mcp/go.mod. Keeping this explicit also avoids a runtime toolchain |
| 173 | # download during the cross-compile. |
| 174 | go-version: "1.26" |
| 175 | cache: false |
| 176 | |
| 177 | - name: Sync engine into vendored/ |
| 178 | run: bash mcp/scripts/sync-engine.sh |
| 179 | |
| 180 | - name: Build MCP binary |
| 181 | env: |
| 182 | GOOS: ${{ matrix.goos }} |
| 183 | GOARCH: ${{ matrix.goarch }} |
| 184 | CGO_ENABLED: "0" |
| 185 | RELEASE_VERSION: ${{ needs.validate.outputs.tag }} |
| 186 | run: | |
| 187 | set -euo pipefail |
| 188 | if ! [[ "${RELEASE_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 189 | echo "::error::Invalid RELEASE_VERSION format for Go ldflags." |
| 190 | exit 1 |
| 191 | fi |
| 192 | mkdir -p mcp/build |
| 193 | go -C mcp build \ |
| 194 | -ldflags "-X main.Version=${RELEASE_VERSION}" \ |
| 195 | -o build/last30days-pp-mcp \ |
| 196 | ./cmd/last30days-pp-mcp |
| 197 | |
| 198 | - name: Bundle .mcpb |
| 199 | # Keep this equivalent to printing-press's bundle layout without |
| 200 | # downloading a separate packager: manifest.json at the ZIP root and |
| 201 | # the executable at its declared server.entry_point. |
| 202 | run: | |
| 203 | set -euo pipefail |
| 204 | entry_point="$(jq -er '.server.entry_point' mcp/manifest.json)" |
| 205 | test "${entry_point}" = "bin/last30days-pp-mcp" |
| 206 | |
| 207 | staging="${RUNNER_TEMP}/last30days-mcpb" |
| 208 | output="${GITHUB_WORKSPACE}/${MCPB_OUTPUT}" |
| 209 | mkdir -p "${staging}/bin" "$(dirname "${output}")" |
| 210 | cp mcp/manifest.json "${staging}/manifest.json" |
| 211 | cp mcp/build/last30days-pp-mcp "${staging}/${entry_point}" |
| 212 | chmod 0755 "${staging}/${entry_point}" |
| 213 | |
| 214 | ( |
| 215 | cd "${staging}" |
| 216 | zip -q -X "${output}" manifest.json "${entry_point}" |
| 217 | ) |
| 218 | unzip -Z1 "${output}" | grep -Fxq "manifest.json" |
| 219 | unzip -Z1 "${output}" | grep -Fxq "${entry_point}" |
| 220 | |
| 221 | - name: Attest .mcpb artifact provenance |
| 222 | uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 |
| 223 | with: |
| 224 | subject-path: ${{ env.MCPB_OUTPUT }} |
| 225 | |
| 226 | - name: Upload .mcpb artifact |
| 227 | uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 228 | with: |
| 229 | name: mcpb-${{ matrix.goos }}-${{ matrix.goarch }} |
| 230 | path: ${{ env.MCPB_OUTPUT }} |
| 231 | |
| 232 | # Build standalone native last30days-core binaries so end users never need a |
| 233 | # Rust toolchain installed. Linux targets build statically against musl so |
| 234 | # they run on any Linux distro/container regardless of glibc version. |
| 235 | build-rust-core: |
| 236 | needs: [validate] |
| 237 | runs-on: ${{ matrix.runner }} |
| 238 | permissions: |
| 239 | contents: read |
| 240 | id-token: write |
| 241 | attestations: write |
| 242 | strategy: |
| 243 | fail-fast: false |
| 244 | matrix: |
| 245 | include: |
| 246 | - runner: macos-latest |
| 247 | platform: darwin-arm64 |
| 248 | target: aarch64-apple-darwin |
| 249 | ext: "" |
| 250 | - runner: macos-latest |
| 251 | platform: darwin-amd64 |
| 252 | target: x86_64-apple-darwin |
| 253 | ext: "" |
| 254 | - runner: ubuntu-latest |
| 255 | platform: linux-amd64 |
| 256 | target: x86_64-unknown-linux-musl |
| 257 | ext: "" |
| 258 | - runner: ubuntu-24.04-arm |
| 259 | platform: linux-arm64 |
| 260 | target: aarch64-unknown-linux-musl |
| 261 | ext: "" |
| 262 | - runner: windows-latest |
| 263 | platform: windows-amd64 |
| 264 | target: x86_64-pc-windows-msvc |
| 265 | ext: ".exe" |
| 266 | steps: |
| 267 | - name: Checkout |
| 268 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 269 | with: |
| 270 | ref: refs/tags/${{ needs.validate.outputs.tag }} |
| 271 | persist-credentials: false |
| 272 | |
| 273 | - name: Verify checked-out tag commit |
| 274 | shell: bash |
| 275 | env: |
| 276 | EXPECTED_COMMIT: ${{ needs.validate.outputs.commit }} |
| 277 | run: | |
| 278 | set -euo pipefail |
| 279 | HEAD_COMMIT="$(git rev-parse --verify HEAD)" |
| 280 | if [ "${HEAD_COMMIT}" != "${EXPECTED_COMMIT}" ]; then |
| 281 | echo "::error::Checked-out HEAD (${HEAD_COMMIT}) does not match validated commit ${EXPECTED_COMMIT}." |
| 282 | exit 1 |
| 283 | fi |
| 284 | |
| 285 | - name: Build release binary |
| 286 | shell: bash |
| 287 | env: |
| 288 | PLATFORM: ${{ matrix.platform }} |
| 289 | RUST_TARGET: ${{ matrix.target }} |
| 290 | BIN_EXT: ${{ matrix.ext }} |
| 291 | run: | |
| 292 | set -euo pipefail |
| 293 | if [[ "${RUST_TARGET}" == *-musl ]]; then |
| 294 | sudo apt-get update |
| 295 | sudo apt-get install -y --no-install-recommends musl-tools |
| 296 | export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc |
| 297 | export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc |
| 298 | fi |
| 299 | rustup target add "${RUST_TARGET}" |
| 300 | cargo build --manifest-path rust/Cargo.toml --release --locked --target "${RUST_TARGET}" |
| 301 | mkdir -p rust/dist |
| 302 | cp "rust/target/${RUST_TARGET}/release/last30days-core${BIN_EXT}" "rust/dist/last30days-core-${PLATFORM}${BIN_EXT}" |
| 303 | if [ -z "${BIN_EXT}" ]; then |
| 304 | chmod 0755 "rust/dist/last30days-core-${PLATFORM}" |
| 305 | fi |
| 306 | |
| 307 | - name: Attest last30days-core artifact provenance |
| 308 | uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2 |
| 309 | with: |
| 310 | subject-path: rust/dist/last30days-core-${{ matrix.platform }}${{ matrix.ext }} |
| 311 | |
| 312 | - name: Upload last30days-core artifact |
| 313 | uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 |
| 314 | with: |
| 315 | name: rust-core-${{ matrix.platform }} |
| 316 | path: rust/dist/last30days-core-${{ matrix.platform }}${{ matrix.ext }} |
| 317 | |
| 318 | # Gather every platform artifact and attach to one GitHub release. |
| 319 | release: |
| 320 | needs: [validate, build-skill, build-mcpb, build-rust-core] |
| 321 | runs-on: ubuntu-latest |
| 322 | permissions: |
| 323 | actions: read |
| 324 | contents: write |
| 325 | steps: |
| 326 | # gh release create --verify-tag shells out to git, so the job needs a |
| 327 | # checkout with the tag present; without it the step fails with |
| 328 | # "fatal: not a git repository". |
| 329 | - name: Checkout |
| 330 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 331 | with: |
| 332 | ref: refs/tags/${{ needs.validate.outputs.tag }} |
| 333 | fetch-depth: 0 |
| 334 | persist-credentials: false |
| 335 | |
| 336 | - name: Verify checked-out tag commit |
| 337 | env: |
| 338 | RELEASE_TAG: ${{ needs.validate.outputs.tag }} |
| 339 | EXPECTED_COMMIT: ${{ needs.validate.outputs.commit }} |
| 340 | run: | |
| 341 | set -euo pipefail |
| 342 | TAG_COMMIT="$(git rev-parse --verify "refs/tags/${RELEASE_TAG}^{commit}")" |
| 343 | HEAD_COMMIT="$(git rev-parse --verify HEAD)" |
| 344 | if [ "${TAG_COMMIT}" != "${EXPECTED_COMMIT}" ] || [ "${HEAD_COMMIT}" != "${EXPECTED_COMMIT}" ]; then |
| 345 | echo "::error::Tag ref ${RELEASE_TAG} no longer resolves to validated commit ${EXPECTED_COMMIT}." |
| 346 | exit 1 |
| 347 | fi |
| 348 | |
| 349 | - name: Download all artifacts |
| 350 | uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 |
| 351 | with: |
| 352 | path: dist |
| 353 | merge-multiple: true |
| 354 | |
| 355 | - name: Generate last30days-core SHA-256 checksums |
| 356 | run: | |
| 357 | set -euo pipefail |
| 358 | rm -f dist/last30days-core-SHA256SUMS.txt |
| 359 | ( |
| 360 | cd dist |
| 361 | sha256sum last30days-core-* > "${RUNNER_TEMP}/last30days-core-SHA256SUMS.txt" |
| 362 | ) |
| 363 | mv "${RUNNER_TEMP}/last30days-core-SHA256SUMS.txt" dist/last30days-core-SHA256SUMS.txt |
| 364 | cat dist/last30days-core-SHA256SUMS.txt |
| 365 | |
| 366 | - name: Create GitHub release |
| 367 | env: |
| 368 | GH_TOKEN: ${{ github.token }} |
| 369 | RELEASE_TAG: ${{ needs.validate.outputs.tag }} |
| 370 | run: | |
| 371 | gh release create "${RELEASE_TAG}" \ |
| 372 | dist/last30days.skill \ |
| 373 | dist/last30days-pp-mcp-*.mcpb \ |
| 374 | dist/last30days-core-* \ |
| 375 | --generate-notes \ |
| 376 | --verify-tag |
| 377 |