Skip to content

Commit 4f7d5ae

Browse files
authored
Add Bitwarden provider support (#13)
1 parent 37aee2c commit 4f7d5ae

15 files changed

Lines changed: 2334 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,48 @@ jobs:
3737
- name: Set up Cloud SDK
3838
uses: google-github-actions/setup-gcloud@v2
3939

40+
- name: Install Bitwarden CLI
41+
run: |
42+
BW_DOWNLOAD_URL=$(curl -s https://api.github.com/repos/bitwarden/cli/releases/latest | grep '"browser_download_url".*linux.*zip' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
43+
curl -L "${BW_DOWNLOAD_URL}" -o bw.zip
44+
unzip -q bw.zip
45+
chmod +x bw
46+
sudo mv bw /usr/local/bin/
47+
rm bw.zip
48+
bw --version
49+
4050
- name: Run end-to-end tests
4151
env:
52+
CGO_LDFLAGS: -lm
4253
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
54+
SSTART_E2E_BITWARDEN_ORGANIZATION_ID: ${{ secrets.SSTART_E2E_BITWARDEN_ORGANIZATION_ID }}
55+
BITWARDEN_SM_ACCESS_TOKEN: ${{ secrets.BITWARDEN_SM_ACCESS_TOKEN }}
56+
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
57+
BW_CLIENTSECRET: ${{ secrets.BW_CLIENTSECRET }}
58+
BW_CLIENTID: ${{ secrets.BW_CLIENTID }}
4359
run: go test -v ./tests/end2end/...
4460

4561
build:
4662
name: Build
47-
runs-on: ubuntu-latest
63+
strategy:
64+
matrix:
65+
include:
66+
- goos: linux
67+
goarch: amd64
68+
runner: ubuntu-latest
69+
- goos: linux
70+
goarch: arm64
71+
runner: ubuntu-latest
72+
- goos: darwin
73+
goarch: amd64
74+
runner: macos-latest
75+
- goos: darwin
76+
goarch: arm64
77+
runner: macos-latest
78+
- goos: windows
79+
goarch: amd64
80+
runner: windows-latest
81+
runs-on: ${{ matrix.runner }}
4882
steps:
4983
- name: Checkout code
5084
uses: actions/checkout@v4
@@ -54,19 +88,29 @@ jobs:
5488
with:
5589
go-version-file: go.mod
5690

57-
- name: Run GoReleaser
58-
uses: goreleaser/goreleaser-action@v5
59-
with:
60-
distribution: goreleaser
61-
version: latest
62-
args: build --snapshot --clean
91+
- name: Install Linux ARM64 cross-compilation toolchain (Linux ARM64 only)
92+
if: matrix.goos == 'linux' && matrix.goarch == 'arm64'
93+
run: |
94+
sudo apt-get update
95+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
96+
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
97+
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
98+
echo "AR=aarch64-linux-gnu-ar" >> $GITHUB_ENV
99+
echo "AS=aarch64-linux-gnu-as" >> $GITHUB_ENV
100+
101+
- name: Build binary
63102
env:
64-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
103+
CGO_ENABLED: 1
104+
CGO_LDFLAGS: -lm
105+
GOOS: ${{ matrix.goos }}
106+
GOARCH: ${{ matrix.goarch }}
107+
run: |
108+
go build -ldflags="-s -w -X github.com/dirathea/sstart/internal/cli.version=snapshot -X github.com/dirathea/sstart/internal/cli.commit=${{ github.sha }} -X github.com/dirathea/sstart/internal/cli.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o sstart${{ matrix.goos == 'windows' && '.exe' || '' }} ./cmd/sstart
65109
66-
- name: Upload artifacts
110+
- name: Upload artifact
67111
uses: actions/upload-artifact@v4
68112
with:
69-
name: sstart-binaries
70-
path: dist/*
113+
name: sstart-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
114+
path: sstart${{ matrix.goos == 'windows' && '.exe' || '' }}
71115
retention-days: 1
72116

.github/workflows/release.yml

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,32 +35,119 @@ jobs:
3535
- name: Set up Cloud SDK
3636
uses: google-github-actions/setup-gcloud@v2
3737

38+
- name: Install Bitwarden CLI
39+
run: |
40+
BW_DOWNLOAD_URL=$(curl -s https://api.github.com/repos/bitwarden/cli/releases/latest | grep '"browser_download_url".*linux.*zip' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
41+
curl -L "${BW_DOWNLOAD_URL}" -o bw.zip
42+
unzip -q bw.zip
43+
chmod +x bw
44+
sudo mv bw /usr/local/bin/
45+
rm bw.zip
46+
bw --version
47+
3848
- name: Run end-to-end tests
3949
env:
50+
CGO_LDFLAGS: -lm
4051
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
52+
SSTART_E2E_BITWARDEN_ORGANIZATION_ID: ${{ secrets.SSTART_E2E_BITWARDEN_ORGANIZATION_ID }}
53+
BITWARDEN_SM_ACCESS_TOKEN: ${{ secrets.BITWARDEN_SM_ACCESS_TOKEN }}
54+
BW_PASSWORD: ${{ secrets.BW_PASSWORD }}
55+
BW_CLIENTSECRET: ${{ secrets.BW_CLIENTSECRET }}
56+
BW_CLIENTID: ${{ secrets.BW_CLIENTID }}
4157
run: go test -v ./tests/end2end/...
4258

4359
release:
4460
name: Build and Release
4561
needs: test
62+
strategy:
63+
matrix:
64+
include:
65+
- build_id: sstart-linux-amd64
66+
runner: ubuntu-latest
67+
- build_id: sstart-linux-arm64
68+
runner: ubuntu-latest
69+
- build_id: sstart-darwin-amd64
70+
runner: macos-latest
71+
- build_id: sstart-darwin-arm64
72+
runner: macos-latest
73+
- build_id: sstart-windows-amd64
74+
runner: windows-latest
75+
runs-on: ${{ matrix.runner }}
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v4
79+
with:
80+
fetch-depth: 0
81+
82+
- name: Set up Go
83+
uses: actions/setup-go@v5
84+
with:
85+
go-version-file: go.mod
86+
87+
- name: Install Linux ARM64 cross-compilation toolchain (Linux ARM64 only)
88+
if: matrix.build_id == 'sstart-linux-arm64'
89+
run: |
90+
sudo apt-get update
91+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
92+
echo "CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
93+
echo "CXX=aarch64-linux-gnu-g++" >> $GITHUB_ENV
94+
echo "AR=aarch64-linux-gnu-ar" >> $GITHUB_ENV
95+
echo "AS=aarch64-linux-gnu-as" >> $GITHUB_ENV
96+
97+
- name: Run GoReleaser (build only)
98+
uses: goreleaser/goreleaser-action@v5
99+
with:
100+
distribution: goreleaser
101+
version: latest
102+
args: build --clean --id=${{ matrix.build_id }}
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
106+
- name: Upload build artifacts
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: dist-${{ matrix.build_id }}
110+
path: dist/*
111+
retention-days: 1
112+
113+
package:
114+
name: Package and Release
115+
needs: release
46116
runs-on: ubuntu-latest
117+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
47118
steps:
48119
- name: Checkout code
49120
uses: actions/checkout@v4
50121
with:
51122
fetch-depth: 0
52123

124+
- name: Download all build artifacts
125+
uses: actions/download-artifact@v4
126+
with:
127+
path: dist-artifacts
128+
53129
- name: Set up Go
54130
uses: actions/setup-go@v5
55131
with:
56132
go-version-file: go.mod
57133

58-
- name: Run GoReleaser
134+
- name: Prepare dist directory for GoReleaser
135+
run: |
136+
mkdir -p dist
137+
# GoReleaser expects binaries in dist/ with specific naming
138+
# Copy binaries maintaining GoReleaser's expected structure
139+
for dir in dist-artifacts/*/; do
140+
if [ -d "$dir" ]; then
141+
cp -r "$dir"* dist/ 2>/dev/null || true
142+
fi
143+
done
144+
145+
- name: Run GoReleaser (package and release)
59146
uses: goreleaser/goreleaser-action@v5
60147
with:
61148
distribution: goreleaser
62149
version: latest
63-
args: release --clean
150+
args: release --clean --skip-build --skip-validate
64151
env:
65152
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66153

.goreleaser.yml

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,76 @@
11
project_name: sstart
22

33
builds:
4-
- id: sstart
4+
- id: sstart-linux-amd64
55
main: ./cmd/sstart
66
binary: sstart
77
goos:
88
- linux
9+
goarch:
10+
- amd64
11+
env:
12+
- CGO_ENABLED=1
13+
- CGO_LDFLAGS=-lm
14+
ldflags:
15+
- -s -w
16+
- -X github.com/dirathea/sstart/internal/cli.version={{.Version}}
17+
- -X github.com/dirathea/sstart/internal/cli.commit={{.Commit}}
18+
- -X github.com/dirathea/sstart/internal/cli.date={{.Date}}
19+
- id: sstart-linux-arm64
20+
main: ./cmd/sstart
21+
binary: sstart
22+
goos:
23+
- linux
24+
goarch:
25+
- arm64
26+
env:
27+
- CGO_ENABLED=1
28+
- CGO_LDFLAGS=-lm
29+
ldflags:
30+
- -s -w
31+
- -X github.com/dirathea/sstart/internal/cli.version={{.Version}}
32+
- -X github.com/dirathea/sstart/internal/cli.commit={{.Commit}}
33+
- -X github.com/dirathea/sstart/internal/cli.date={{.Date}}
34+
- id: sstart-darwin-amd64
35+
main: ./cmd/sstart
36+
binary: sstart
37+
goos:
938
- darwin
10-
- windows
1139
goarch:
1240
- amd64
41+
env:
42+
- CGO_ENABLED=1
43+
- CGO_LDFLAGS=-lm
44+
ldflags:
45+
- -s -w
46+
- -X github.com/dirathea/sstart/internal/cli.version={{.Version}}
47+
- -X github.com/dirathea/sstart/internal/cli.commit={{.Commit}}
48+
- -X github.com/dirathea/sstart/internal/cli.date={{.Date}}
49+
- id: sstart-darwin-arm64
50+
main: ./cmd/sstart
51+
binary: sstart
52+
goos:
53+
- darwin
54+
goarch:
1355
- arm64
1456
env:
15-
- CGO_ENABLED=0
57+
- CGO_ENABLED=1
58+
- CGO_LDFLAGS=-lm
59+
ldflags:
60+
- -s -w
61+
- -X github.com/dirathea/sstart/internal/cli.version={{.Version}}
62+
- -X github.com/dirathea/sstart/internal/cli.commit={{.Commit}}
63+
- -X github.com/dirathea/sstart/internal/cli.date={{.Date}}
64+
- id: sstart-windows-amd64
65+
main: ./cmd/sstart
66+
binary: sstart
67+
goos:
68+
- windows
69+
goarch:
70+
- amd64
71+
env:
72+
- CGO_ENABLED=1
73+
- CGO_LDFLAGS=-lm
1674
ldflags:
1775
- -s -w
1876
- -X github.com/dirathea/sstart/internal/cli.version={{.Version}}

0 commit comments

Comments
 (0)