-
Notifications
You must be signed in to change notification settings - Fork 0
feat: background auto-update with SHA256 verification #5
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
Show all changes
15 commits
Select commit
Hold shift + click to select a range
63918b2
feat: background auto-update with SHA256 verification
bhagyamudgal 121de31
fix: address PR #5 review — hardening follow-ups
bhagyamudgal 66e746a
fix: ai comments
bhagyamudgal d8aceae
fix: harden PR #5 auto-update — re-verify on apply, fail-closed confi…
bhagyamudgal af3db7a
fix: ai comment
bhagyamudgal cb33f2e
fix: harden PR #5 auto-update from self-review findings
bhagyamudgal 7a4c6cf
fix: harden PR #5 auto-update from self-review findings (15 hardening…
bhagyamudgal 7bc2f69
fix:
bhagyamudgal 46caeb1
fix: harden PR #5 from self-review — silent downgrade, host pinning, …
bhagyamudgal c5ceded
refactor: trim verbose auto-update comments
bhagyamudgal bf3a0a8
fix: address CodeRabbit PR #5 review — 6 auto-update hardenings
bhagyamudgal a9d7ca4
docs(changelog): add [Unreleased] and rewrite 1.3.0 user-facing
bhagyamudgal d99ca77
fix: address 15 self-review findings on PR #5
bhagyamudgal ac03eb5
fix: add try catch in readConfigFile function
bhagyamudgal b6009a0
fix: comments
bhagyamudgal 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
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 |
|---|---|---|
| @@ -1,55 +1,140 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: ["v*"] | ||
| push: | ||
| tags: ["v*"] | ||
|
|
||
| permissions: | ||
| contents: write | ||
| contents: write | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build ${{ matrix.target }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - target: darwin-arm64 | ||
| os: macos-latest | ||
| bun_target: bun-darwin-arm64 | ||
| - target: darwin-x64 | ||
| os: macos-15-intel | ||
| bun_target: bun-darwin-x64 | ||
| - target: linux-x64 | ||
| os: ubuntu-latest | ||
| bun_target: bun-linux-x64 | ||
| - target: linux-arm64 | ||
| os: ubuntu-latest | ||
| bun_target: bun-linux-arm64 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - run: bun install --frozen-lockfile | ||
| - run: bun build src/index.ts --compile --target=${{ matrix.bun_target }} --outfile dist/worktree-${{ matrix.target }} | ||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: worktree-${{ matrix.target }} | ||
| path: dist/worktree-${{ matrix.target }} | ||
|
|
||
| release: | ||
| name: Create Release | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| path: artifacts | ||
| merge-multiple: true | ||
|
|
||
| - run: chmod +x artifacts/worktree-* | ||
|
|
||
| - uses: softprops/action-gh-release@v2 | ||
| with: | ||
| generate_release_notes: true | ||
| files: artifacts/worktree-* | ||
| build: | ||
| name: Build ${{ matrix.target }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - target: darwin-arm64 | ||
| os: macos-latest | ||
| bun_target: bun-darwin-arm64 | ||
| - target: darwin-x64 | ||
| os: macos-15-intel | ||
| bun_target: bun-darwin-x64 | ||
| - target: linux-x64 | ||
| os: ubuntu-latest | ||
| bun_target: bun-linux-x64 | ||
| - target: linux-arm64 | ||
| os: ubuntu-24.04-arm | ||
| bun_target: bun-linux-arm64 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: oven-sh/setup-bun@v2 | ||
| - run: bun install --frozen-lockfile | ||
|
|
||
| - name: Compile binary | ||
| run: | | ||
| bun build src/index.ts \ | ||
| --compile \ | ||
| --minify \ | ||
| --sourcemap=none \ | ||
| --target=${{ matrix.bun_target }} \ | ||
| --outfile dist/worktree-${{ matrix.target }} | ||
|
|
||
| - name: Install llvm-strip (Linux) | ||
| if: startsWith(matrix.target, 'linux-') | ||
| run: sudo apt-get update && sudo apt-get install -y llvm | ||
|
|
||
| - name: Strip symbols (Linux) | ||
| if: startsWith(matrix.target, 'linux-') | ||
| run: llvm-strip --strip-unneeded dist/worktree-${{ matrix.target }} | ||
|
|
||
| - name: Strip symbols (macOS) | ||
| if: startsWith(matrix.target, 'darwin-') | ||
| run: strip dist/worktree-${{ matrix.target }} | ||
|
|
||
| - name: Ad-hoc codesign (macOS) | ||
| if: startsWith(matrix.target, 'darwin-') | ||
| run: | | ||
| xattr -cr dist/worktree-${{ matrix.target }} | ||
| codesign --force --sign - dist/worktree-${{ matrix.target }} | ||
| codesign -dv dist/worktree-${{ matrix.target }} | ||
|
|
||
| - name: Verify binary architecture and size | ||
| run: | | ||
| file dist/worktree-${{ matrix.target }} | ||
| ls -lh dist/worktree-${{ matrix.target }} | ||
|
|
||
| - name: Smoke-test --version | ||
| env: | ||
| WORKTREE_NO_UPDATE: "1" | ||
| run: | | ||
| chmod +x dist/worktree-${{ matrix.target }} | ||
| ./dist/worktree-${{ matrix.target }} --version | ||
|
|
||
| - name: Compute SHA256 | ||
| run: | | ||
| cd dist | ||
| shasum -a 256 worktree-${{ matrix.target }} > worktree-${{ matrix.target }}.sha256 | ||
|
|
||
| - uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: worktree-${{ matrix.target }} | ||
| path: | | ||
| dist/worktree-${{ matrix.target }} | ||
| dist/worktree-${{ matrix.target }}.sha256 | ||
|
|
||
| release: | ||
| name: Create Release | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| path: artifacts | ||
| merge-multiple: true | ||
|
|
||
| - name: Aggregate SHA256SUMS | ||
| run: | | ||
| cd artifacts | ||
| # Fail-fast: if no .sha256 sidecars were downloaded (e.g., | ||
| # an upload-artifact rename regression), the cat below | ||
| # would silently produce an empty SHA256SUMS that bricks | ||
| # every client's auto-update install. | ||
| count=$(ls -1 worktree-*.sha256 2>/dev/null | wc -l | tr -d ' ') | ||
| binaries=$(ls -1 worktree-* 2>/dev/null | grep -v '\.sha256$' | wc -l | tr -d ' ') | ||
| if [ "$count" -lt 1 ] || [ "$count" != "$binaries" ]; then | ||
| echo "sha256 count ($count) does not match binary count ($binaries) — abort" >&2 | ||
| exit 1 | ||
| fi | ||
| cat worktree-*.sha256 > SHA256SUMS | ||
| rm worktree-*.sha256 | ||
| if [ ! -s SHA256SUMS ]; then | ||
| echo "SHA256SUMS empty after aggregation — abort" >&2 | ||
| exit 1 | ||
| fi | ||
| cat SHA256SUMS | ||
|
|
||
| - run: chmod +x artifacts/worktree-* | ||
|
|
||
| # Create the release as a draft and upload all assets to it. | ||
| # Publishing happens in the next step so `releases/latest` never | ||
| # returns a release where binaries are attached but SHA256SUMS | ||
| # is still being uploaded — that window would let clients fall | ||
| # through to the TLS-only "not-published" path and install | ||
| # unverified. | ||
| - uses: softprops/action-gh-release@v2 | ||
| with: | ||
| draft: true | ||
| generate_release_notes: true | ||
| files: | | ||
| artifacts/worktree-* | ||
| artifacts/SHA256SUMS | ||
|
|
||
| - name: Publish release (flip draft to public) | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| REF_NAME: ${{ github.ref_name }} | ||
| REPO: ${{ github.repository }} | ||
| run: | | ||
| gh release edit "$REF_NAME" --repo "$REPO" --draft=false | ||
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 |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ node_modules/ | |
| dist/ | ||
| .worktrees | ||
| docs/ | ||
| tasks/ | ||
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.
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.