-
Notifications
You must be signed in to change notification settings - Fork 18
Make basecamp upgrade a real upgrade: native, verified self-update #615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,212 @@ | ||
| --- | ||
| # Upgrade smoke: end-to-end proof that `basecamp upgrade` self-updates a | ||
| # stale binary against the REAL latest release — real download, real Sigstore | ||
| # verification, and (on Windows) the real locked-exe rename shuffle — plus | ||
| # installer legs pinning the cosign version→flag capability gate against the | ||
| # published bundle format. | ||
| name: Upgrade Smoke | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "internal/commands/upgrade*" | ||
| - "internal/commands/doctor.go" | ||
| - "internal/version/**" | ||
| - "go.mod" | ||
| - "go.sum" | ||
| - ".goreleaser.yaml" | ||
| - "scripts/install.sh" | ||
| - "scripts/install.ps1" | ||
| - ".github/workflows/upgrade-smoke.yml" | ||
| pull_request: | ||
| paths: | ||
| - "internal/commands/upgrade*" | ||
| - "internal/commands/doctor.go" | ||
| - "internal/version/**" | ||
| - "go.mod" | ||
| - "go.sum" | ||
| - ".goreleaser.yaml" | ||
| - "scripts/install.sh" | ||
| - "scripts/install.ps1" | ||
| - ".github/workflows/upgrade-smoke.yml" | ||
|
|
||
| permissions: {} | ||
|
|
||
| concurrency: | ||
| group: upgrade-smoke-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| native-upgrade: | ||
| name: native self-update (${{ matrix.os }}) | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest, windows-latest] | ||
| runs-on: ${{ matrix.os }} | ||
| permissions: | ||
| contents: read | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Build a stale 0.0.1 binary under HOME | ||
| run: | | ||
| ext="" | ||
| [[ "$RUNNER_OS" == "Windows" ]] && ext=".exe" | ||
| mkdir -p "$HOME/bin" | ||
| go build \ | ||
| -ldflags "-X github.com/basecamp/basecamp-cli/internal/version.Version=0.0.1" \ | ||
| -o "$HOME/bin/basecamp$ext" ./cmd/basecamp | ||
| "$HOME/bin/basecamp$ext" --version | ||
|
|
||
| - name: Run basecamp upgrade against the real latest release | ||
| env: | ||
| BASECAMP_NO_KEYRING: "1" | ||
| # Anonymous api.github.com requests share the runner egress IP's | ||
| # rate limit; the CLI attaches this token to its releases/latest | ||
| # lookup (attachGitHubAuth) so the check can't 403. | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: | | ||
| ext="" | ||
| [[ "$RUNNER_OS" == "Windows" ]] && ext=".exe" | ||
| "$HOME/bin/basecamp$ext" upgrade | ||
|
|
||
| - name: Assert the installed binary reports the latest release | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| ext="" | ||
| [[ "$RUNNER_OS" == "Windows" ]] && ext=".exe" | ||
| latest=$(gh api repos/basecamp/basecamp-cli/releases/latest --jq .tag_name) | ||
| latest="${latest#v}" | ||
| got=$("$HOME/bin/basecamp$ext" --version | awk '{print $NF}') | ||
| echo "latest=$latest installed=$got" | ||
| test "$got" = "$latest" | ||
|
|
||
| installer-sh: | ||
| name: install.sh cosign ${{ matrix.cosign }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # sha256 values come from each cosign release's cosign_checksums.txt. | ||
| include: | ||
| - cosign: v3.0.5 # new bundle format is the default: bare verify-blob | ||
| sha256: db15cc99e6e4837daabab023742aaddc3841ce57f193d11b7c3e06c8003642b2 | ||
| expect: verified | ||
| - cosign: v2.6.0 # floor for --new-bundle-format=true | ||
| sha256: ea5c65f99425d6cfbb5c4b5de5dac035f14d09131c1a0ea7c7fc32eab39364f9 | ||
| expect: verified | ||
| - cosign: v2.4.0 # unsupported: warn + skip, install still succeeds | ||
| sha256: cd7636b3586a3bdac2d9c8f3b421ed119edcb20499107887fd929211110e8418 | ||
| expect: skipped | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install cosign ${{ matrix.cosign }} (digest-pinned) | ||
| run: | | ||
| curl -fsSL -o /tmp/cosign \ | ||
| "https://github.com/sigstore/cosign/releases/download/${{ matrix.cosign }}/cosign-linux-amd64" | ||
| echo "${{ matrix.sha256 }} /tmp/cosign" | sha256sum -c - | ||
| chmod +x /tmp/cosign | ||
| sudo mv /tmp/cosign /usr/local/bin/cosign | ||
| cosign version | ||
|
|
||
| - name: Run install.sh against the latest release | ||
| env: | ||
| BASECAMP_BIN_DIR: /home/runner/.local/bin | ||
| BASECAMP_SKIP_SETUP: "1" | ||
| BASECAMP_SETUP_AGENT: none | ||
| BASECAMP_NO_KEYRING: "1" | ||
| run: | | ||
| set -o pipefail | ||
| bash scripts/install.sh | tee install.log | ||
|
|
||
| - name: Assert the signature verification path | ||
| run: | | ||
| if [[ "${{ matrix.expect }}" == "verified" ]]; then | ||
| grep -q "Signature verified" install.log | ||
| else | ||
| grep -q "Skipping signature verification" install.log | ||
| if grep -q "Signature verified" install.log; then | ||
| echo "must not claim the signature was verified" >&2 | ||
| exit 1 | ||
| fi | ||
| fi | ||
| grep -q "Checksum verified" install.log | ||
| "$HOME/.local/bin/basecamp" --version | ||
|
|
||
| installer-ps1: | ||
| name: install.ps1 cosign ${{ matrix.cosign }} | ||
| runs-on: windows-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| # sha256 values come from each cosign release's cosign_checksums.txt. | ||
| include: | ||
| - cosign: v3.0.5 | ||
| sha256: 44e9e44202b67ddfaaf5ea1234f5a265417960c4ae98c5b57c35bc40ba9dd714 | ||
| expect: verified | ||
| - cosign: v2.6.0 | ||
| sha256: 7beb4dd1e19a72c328bbf7c0d7342d744edbf5cbb082f227b2b76e04a21c16ef | ||
| expect: verified | ||
| - cosign: v2.4.0 | ||
| sha256: 88f1addbae6bdd83ec2c067470c1f56b6d0d3ba35f49ad34603f2502cb2933f3 | ||
| expect: skipped | ||
| permissions: | ||
| contents: read | ||
| defaults: | ||
| run: | ||
| shell: pwsh | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install cosign ${{ matrix.cosign }} (digest-pinned) | ||
| run: | | ||
| $binDir = Join-Path $env:RUNNER_TEMP 'cosign-bin' | ||
| New-Item -ItemType Directory -Force -Path $binDir | Out-Null | ||
| $exe = Join-Path $binDir 'cosign.exe' | ||
| Invoke-WebRequest -UseBasicParsing ` | ||
| -Uri "https://github.com/sigstore/cosign/releases/download/${{ matrix.cosign }}/cosign-windows-amd64.exe" ` | ||
| -OutFile $exe | ||
| $actual = (Get-FileHash -Algorithm SHA256 -Path $exe).Hash.ToLowerInvariant() | ||
| if ($actual -ne '${{ matrix.sha256 }}') { throw "cosign digest mismatch: $actual" } | ||
| Add-Content $env:GITHUB_PATH $binDir | ||
|
|
||
| - name: Run install.ps1 against the latest release | ||
| env: | ||
| BASECAMP_SKIP_SETUP: "1" | ||
| BASECAMP_SETUP_AGENT: none | ||
| BASECAMP_NO_KEYRING: "1" | ||
| run: | | ||
| cosign version | ||
| & .\scripts\install.ps1 *>&1 | Tee-Object -FilePath install.log | ||
|
|
||
| - name: Assert the signature verification path | ||
| run: | | ||
| $log = Get-Content install.log -Raw | ||
| if ('${{ matrix.expect }}' -eq 'verified') { | ||
| if ($log -notmatch 'Signature verified') { throw 'expected cosign signature verification' } | ||
| } else { | ||
| if ($log -notmatch "Skipping signature verification") { throw 'expected the skip warning' } | ||
| if ($log -match 'Signature verified') { throw 'must not claim the signature was verified' } | ||
| } | ||
| if ($log -notmatch 'Checksum verified') { throw 'expected checksum verification' } | ||
| & "$env:USERPROFILE\bin\basecamp.exe" --version | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.