Skip to content

Commit 70b662b

Browse files
ci: add github workflows
Signed-off-by: Mathew Wicks <[email protected]>
1 parent 47a35c6 commit 70b662b

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

.github/workflows/check-pr.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Check PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v4
17+
with:
18+
go-version: 1.19
19+
20+
- name: Install golangci-lint
21+
run: |
22+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
23+
24+
- name: Lint Code
25+
run: make lint
26+
27+
test:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Check out code
31+
uses: actions/checkout@v3
32+
33+
- name: Set up Go
34+
uses: actions/setup-go@v4
35+
with:
36+
go-version: 1.19
37+
38+
- name: Run Tests
39+
run: make test
40+
41+
build:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Check out code
45+
uses: actions/checkout@v3
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@v4
49+
with:
50+
go-version: 1.19
51+
52+
- name: Build single target
53+
run: make build

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build_and_release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v3
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v4
20+
with:
21+
go-version: 1.19
22+
23+
- name: Build all targets
24+
run: make build-all
25+
26+
- name: Compute checksums
27+
run: |
28+
cd bin
29+
for file in deploykf-*; do
30+
sha256sum "$file" > "$file.sha256"
31+
done
32+
33+
- name: Create GitHub Release
34+
id: create_release
35+
uses: actions/create-release@v1
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
with:
39+
tag_name: ${{ github.ref }}
40+
release_name: Release ${{ github.ref }}
41+
draft: true
42+
prerelease: ${{ contains(github.ref, "-') }}
43+
44+
- name: Upload binaries and checksums
45+
run: |
46+
for file in ./bin/deploykf-*; do
47+
asset_name="$(basename $file)"
48+
asset_path="./bin/$asset_name"
49+
asset_checksum_path="./bin/$asset_name.sha256"
50+
51+
echo "Uploading $asset_name"
52+
curl \
53+
--progress-bar \
54+
--location \
55+
--request POST \
56+
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
57+
--header 'Content-Type: application/octet-stream' \
58+
--upload-file "$asset_path" \
59+
--url "${{ steps.create_release.outputs.upload_url }}?name=$asset_name"
60+
61+
echo "Uploading $asset_name.sha256"
62+
curl \
63+
--progress-bar \
64+
--location \
65+
--request POST \
66+
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
67+
--header 'Content-Type: text/plain' \
68+
--upload-file "$asset_checksum_path" \
69+
--url "${{ steps.create_release.outputs.upload_url }}?name=$asset_name.sha256"
70+
done

0 commit comments

Comments
 (0)