Skip to content

Commit 7988939

Browse files
committed
CI/CD
- Set up CI/CD pipelines with 3 jobs (test, build. release)
1 parent 132bfa8 commit 7988939

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

.github/workflows/ci.yml

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: '1.21'
20+
21+
- name: Install Task
22+
run: go install github.com/go-task/task/v3/cmd/task@latest
23+
24+
- name: Run tests
25+
run: task test
26+
27+
build:
28+
needs: test
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
arch: [arm64, arm]
33+
include:
34+
- arch: arm64
35+
goarch: arm64
36+
- arch: arm
37+
goarch: arm
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Set up Go
43+
uses: actions/setup-go@v5
44+
with:
45+
go-version: '1.21'
46+
47+
- name: Build
48+
env:
49+
GOOS: linux
50+
GOARCH: ${{ matrix.goarch }}
51+
CGO_ENABLED: 0
52+
run: |
53+
go build -o bin/bt-hid-relay-${{ matrix.arch }} ./cmd/bt-hid-relay/
54+
55+
- name: Upload artifact
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: bt-hid-relay-${{ matrix.arch }}
59+
path: bin/bt-hid-relay-${{ matrix.arch }}
60+
61+
release:
62+
needs: build
63+
if: startsWith(github.ref, 'refs/tags/v')
64+
runs-on: ubuntu-latest
65+
permissions:
66+
contents: write
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- name: Download all artifacts
71+
uses: actions/download-artifact@v4
72+
with:
73+
path: artifacts
74+
75+
- name: Create Release
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
run: |
79+
# Prepare assets
80+
cd artifacts
81+
for dir in */; do
82+
chmod +x "$dir"*
83+
tar czf "${dir%/}.tar.gz" -C "$dir" .
84+
done
85+
86+
# Create release
87+
gh release create ${{ github.ref_name }} \
88+
--title "Release ${{ github.ref_name }}" \
89+
--notes "Release ${{ github.ref_name }}" \
90+
*.tar.gz

0 commit comments

Comments
 (0)