Skip to content

Commit ca25a59

Browse files
committed
Address PR review feedback
Pin all 7 third-party GitHub Actions to commit SHAs for supply-chain hardening (cosign-installer, sbom-action, goreleaser-action, gitleaks-action, trivy-action, gosec, golangci-lint-action). Fix install.sh checksum grep to use exact filename match via awk instead of substring grep. Fix publish-aur.sh to use curl -f for fail-fast on HTTP errors and skip commit/push when AUR is already up to date. Handle completion generator errors via RunE instead of silently ignoring them.
1 parent 20ca396 commit ca25a59

6 files changed

Lines changed: 37 additions & 118 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,22 @@ jobs:
6767
repositories: homebrew-tap
6868

6969
- name: Install cosign
70-
uses: sigstore/cosign-installer@v3
70+
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # v3
7171

7272
- name: Install Syft
73-
uses: anchore/sbom-action/download-syft@v0
73+
uses: anchore/sbom-action/download-syft@17ae1740179002c89186b61233e0f892c3118b11 # v0
7474

7575
- name: Generate shell completions
7676
run: |
77-
VERSION=${GITHUB_REF_NAME#v}
78-
curl -sL "https://github.com/basecamp/fizzy-cli/releases/download/v${VERSION}/fizzy-linux-${{ matrix.goarch }}" -o fizzy
79-
chmod +x fizzy
77+
go build -o fizzy-tmp ./cmd/fizzy
78+
mkdir -p completions
79+
./fizzy-tmp completion bash > completions/fizzy.bash
80+
./fizzy-tmp completion zsh > completions/fizzy.zsh
81+
./fizzy-tmp completion fish > completions/fizzy.fish
82+
rm fizzy-tmp
8083
8184
- name: Run GoReleaser
82-
uses: goreleaser/goreleaser-action@v6
85+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6
8386
with:
8487
version: '~> v2'
8588
args: release --clean
@@ -104,108 +107,14 @@ jobs:
104107
env:
105108
AUR_KEY: ${{ secrets.AUR_KEY }}
106109
run: |
107-
VERSION=${GITHUB_REF_NAME#v}
108-
109-
# Download source tarball and calculate checksum
110-
curl -sL "https://github.com/basecamp/fizzy-cli/archive/v${VERSION}.tar.gz" -o source.tar.gz
111-
SHA256=$(sha256sum source.tar.gz | cut -d' ' -f1)
112-
113-
# Generate PKGBUILD
114-
cat > PKGBUILD << 'EOF'
115-
# Maintainer: 37signals <support@37signals.com>
116-
pkgname=fizzy-cli
117-
pkgver=VERSION_PLACEHOLDER
118-
pkgrel=1
119-
pkgdesc="CLI for managing Fizzy boards, cards, and tasks"
120-
arch=('x86_64' 'aarch64')
121-
url="https://github.com/basecamp/fizzy-cli"
122-
license=('MIT')
123-
depends=('glibc')
124-
makedepends=('go')
125-
source=("$pkgname-$pkgver.tar.gz::https://github.com/basecamp/fizzy-cli/archive/v$pkgver.tar.gz")
126-
sha256sums=('SHA256_PLACEHOLDER')
127-
options=('!debug')
128-
129-
build() {
130-
cd "$pkgname-$pkgver"
131-
export CGO_CPPFLAGS="${CPPFLAGS}"
132-
export CGO_CFLAGS="${CFLAGS}"
133-
export CGO_CXXFLAGS="${CXXFLAGS}"
134-
export CGO_LDFLAGS="${LDFLAGS}"
135-
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
136-
go build -ldflags "-s -w -X main.version=${pkgver}" -o fizzy ./cmd/fizzy
137-
}
138-
139-
package() {
140-
cd "$pkgname-$pkgver"
141-
install -Dm755 fizzy "$pkgdir/usr/bin/fizzy"
142-
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
143-
}
144-
EOF
145-
146-
# Remove leading whitespace from PKGBUILD
147-
sed -i 's/^ //' PKGBUILD
148-
149-
# Replace placeholders
150-
sed -i "s/VERSION_PLACEHOLDER/$VERSION/" PKGBUILD
151-
sed -i "s/SHA256_PLACEHOLDER/$SHA256/" PKGBUILD
110+
if [ -n "$AUR_KEY" ]; then
111+
echo "available=true" >> "$GITHUB_OUTPUT"
112+
fi
152113
153114
- name: Publish to AUR
154115
if: steps.check.outputs.available == 'true'
155116
run: |
156-
VERSION=${GITHUB_REF_NAME#v}
157-
158-
# Download SHA256 files
159-
curl -sL "https://github.com/basecamp/fizzy-cli/releases/download/v${VERSION}/SHA256SUMS-darwin-amd64.txt" -o sha256-amd64.txt
160-
curl -sL "https://github.com/basecamp/fizzy-cli/releases/download/v${VERSION}/SHA256SUMS-darwin-arm64.txt" -o sha256-arm64.txt
161-
162-
SHA256_AMD64=$(cut -d' ' -f1 sha256-amd64.txt)
163-
SHA256_ARM64=$(cut -d' ' -f1 sha256-arm64.txt)
164-
165-
# Generate formula
166-
cat > fizzy-cli.rb << 'FORMULA'
167-
class FizzyCli < Formula
168-
desc "CLI for managing Fizzy boards, cards, and tasks"
169-
homepage "https://github.com/basecamp/fizzy-cli"
170-
version "VERSION_PLACEHOLDER"
171-
license "MIT"
172-
173-
on_macos do
174-
if Hardware::CPU.arm?
175-
url "https://github.com/basecamp/fizzy-cli/releases/download/v#{version}/fizzy-darwin-arm64"
176-
sha256 "SHA256_ARM64_PLACEHOLDER"
177-
else
178-
url "https://github.com/basecamp/fizzy-cli/releases/download/v#{version}/fizzy-darwin-amd64"
179-
sha256 "SHA256_AMD64_PLACEHOLDER"
180-
end
181-
end
182-
183-
def install
184-
binary_name = Hardware::CPU.arm? ? "fizzy-darwin-arm64" : "fizzy-darwin-amd64"
185-
bin.install binary_name => "fizzy"
186-
end
187-
188-
test do
189-
assert_match version.to_s, shell_output("#{bin}/fizzy --version")
190-
end
191-
end
192-
FORMULA
193-
194-
# Remove leading whitespace and replace placeholders
195-
sed -i 's/^ //' fizzy-cli.rb
196-
sed -i "s/VERSION_PLACEHOLDER/${VERSION}/" fizzy-cli.rb
197-
sed -i "s/SHA256_ARM64_PLACEHOLDER/${SHA256_ARM64}/" fizzy-cli.rb
198-
sed -i "s/SHA256_AMD64_PLACEHOLDER/${SHA256_AMD64}/" fizzy-cli.rb
199-
200-
# Clone tap repo, update formula, push
201-
git clone https://x-access-token:${GH_TOKEN}@github.com/robzolkos/homebrew-fizzy-cli.git
202-
cd homebrew-fizzy-cli
203-
cp ../fizzy-cli.rb Formula/fizzy-cli.rb
204-
git config user.name "github-actions[bot]"
205-
git config user.email "github-actions[bot]@users.noreply.github.com"
206-
git add Formula/fizzy-cli.rb
207-
git commit -m "Update fizzy-cli to ${VERSION}"
208-
git push
117+
scripts/publish-aur.sh
209118
env:
210119
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
211120
AUR_KEY: ${{ secrets.AUR_KEY }}

.github/workflows/security.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- uses: actions/checkout@v4
2222
with:
2323
fetch-depth: 0
24-
- uses: gitleaks/gitleaks-action@v2
24+
- uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2
2525
env:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2727

@@ -31,7 +31,7 @@ jobs:
3131
if: github.event_name != 'pull_request'
3232
steps:
3333
- uses: actions/checkout@v4
34-
- uses: aquasecurity/trivy-action@master
34+
- uses: aquasecurity/trivy-action@97e0b3872f55f89b95b2f65b3dbab56962816478 # v0.34.2
3535
with:
3636
scan-type: fs
3737
format: sarif
@@ -47,7 +47,7 @@ jobs:
4747
if: github.event_name != 'pull_request'
4848
steps:
4949
- uses: actions/checkout@v4
50-
- uses: securego/gosec@master
50+
- uses: securego/gosec@bb17e422fc34bf4c0a2e5cab9d07dc45a68c040c # v2.24.7
5151
with:
5252
args: -fmt sarif -out gosec-results.sarif ./...
5353
- uses: github/codeql-action/upload-sarif@v3

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
run: go vet ./...
5454

5555
- name: golangci-lint
56-
uses: golangci/golangci-lint-action@v7
56+
uses: golangci/golangci-lint-action@9fae48acfc02a90574d7c304a1758ef9895495fa # v7
5757
with:
5858
version: v2.10
5959

internal/commands/completion.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package commands
22

33
import (
4+
"fmt"
45
"os"
56

67
"github.com/spf13/cobra"
@@ -39,17 +40,22 @@ PowerShell:
3940
DisableFlagsInUseLine: true,
4041
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
4142
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
42-
Run: func(cmd *cobra.Command, args []string) {
43+
RunE: func(cmd *cobra.Command, args []string) error {
44+
var err error
4345
switch args[0] {
4446
case "bash":
45-
_ = cmd.Root().GenBashCompletion(os.Stdout)
47+
err = cmd.Root().GenBashCompletion(os.Stdout)
4648
case "zsh":
47-
_ = cmd.Root().GenZshCompletion(os.Stdout)
49+
err = cmd.Root().GenZshCompletion(os.Stdout)
4850
case "fish":
49-
_ = cmd.Root().GenFishCompletion(os.Stdout, true)
51+
err = cmd.Root().GenFishCompletion(os.Stdout, true)
5052
case "powershell":
51-
_ = cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
53+
err = cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
5254
}
55+
if err != nil {
56+
return fmt.Errorf("generating %s completions: %w", args[0], err)
57+
}
58+
return nil
5359
},
5460
}
5561

scripts/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ curl -fsSL "$CHECKSUMS_URL" -o "$TMPDIR/checksums.txt"
4949
# Verify SHA256
5050
echo "Verifying checksum..."
5151
cd "$TMPDIR"
52-
EXPECTED=$(grep "$ARCHIVE" checksums.txt | awk '{print $1}')
52+
EXPECTED=$(awk -v f="$ARCHIVE" '$2 == f {print $1}' checksums.txt)
5353
if [ -z "$EXPECTED" ]; then
5454
echo "WARNING: Archive not found in checksums file"
5555
else

scripts/publish-aur.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ echo "Publishing fizzy-cli $VERSION to AUR..."
1111

1212
# Download checksums from release
1313
CHECKSUM_URL="https://github.com/$REPO/releases/download/v${VERSION}/checksums.txt"
14-
curl -sL "$CHECKSUM_URL" -o checksums.txt
14+
curl -fsSL "$CHECKSUM_URL" -o checksums.txt
1515

1616
# Get source tarball checksum
1717
SOURCE_URL="https://github.com/$REPO/archive/v${VERSION}.tar.gz"
18-
curl -sL "$SOURCE_URL" -o source.tar.gz
18+
curl -fsSL "$SOURCE_URL" -o source.tar.gz
1919
SHA256=$(sha256sum source.tar.gz | cut -d' ' -f1)
2020
rm source.tar.gz
2121

@@ -101,8 +101,12 @@ cd aur-repo
101101
git config user.name "fizzy-release-bot"
102102
git config user.email "fizzy-release-bot@users.noreply.github.com"
103103
git add PKGBUILD .SRCINFO
104-
git commit -m "Update to $VERSION"
105-
git push
104+
if git diff --cached --quiet; then
105+
echo "AUR package already up to date for $VERSION"
106+
else
107+
git commit -m "Update to $VERSION"
108+
git push
109+
fi
106110

107111
echo "Published fizzy-cli $VERSION to AUR"
108112
rm -f checksums.txt

0 commit comments

Comments
 (0)