Skip to content

Commit 22c3a1d

Browse files
committed
feat: Add release workflow
1 parent 49cc6a3 commit 22c3a1d

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Release Workflow
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
name: Build and Release Binaries
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
goos: [linux, darwin, windows]
16+
goarch: [amd64, arm64]
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v4
24+
with:
25+
go-version: 1.24
26+
27+
- name: Build binary
28+
run: |
29+
mkdir -p dist
30+
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/backup-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/backup.go
31+
32+
- name: Generate SHA256 checksum
33+
run: |
34+
for file in dist/*; do
35+
sha256sum "$file" > "$file.sha256";
36+
done
37+
38+
- name: Upload binaries
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: backup-${{ matrix.goos }}-${{ matrix.goarch }}
42+
path: dist/backup-${{ matrix.goos }}-${{ matrix.goarch }}
43+
44+
- name: Upload SHA256 checksum files
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: sha256-checksums-${{ matrix.goos }}-${{ matrix.goarch }}
48+
path: dist/*.sha256
49+
50+
release:
51+
name: Publish Release
52+
needs: build
53+
runs-on: ubuntu-latest
54+
55+
steps:
56+
- name: Download all artifacts
57+
uses: actions/download-artifact@v4
58+
with:
59+
path: dist
60+
merge-multiple: true
61+
62+
- name: Create GitHub Release
63+
uses: ncipollo/release-action@v1
64+
with:
65+
artifacts: dist/*
66+
token: ${{ secrets.GITHUB_TOKEN }}
67+
tag: ${{ github.ref_name }}
68+
name: Release ${{ github.ref_name }}
69+
body: |
70+
Release ${{ github.ref_name }} includes binaries for the following platforms:
71+
- Linux (amd64, arm64)
72+
- macOS (amd64, arm64)
73+
- Windows (amd64, arm64)

0 commit comments

Comments
 (0)