-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (93 loc) · 2.88 KB
/
test-build-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Test, Build, maybe Release
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
jobs:
Test:
runs-on: ubuntu-latest
steps:
- name: Check out tdiscuss
uses: actions/checkout@v4
- name: Cache Bazel
uses: actions/cache@v4
with:
path: |
~/.cache/bazel
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
- name: Go version check
run: make check-go-versions
- name: Test //...
run: bazelisk test --workspace_status_command="${PWD}/status.sh" //...
Build:
needs: Test
runs-on: ubuntu-latest
strategy:
matrix:
goos: [darwin, linux]
goarch: [amd64, arm64]
steps:
- name: Check out tdiscuss
uses: actions/checkout@v4
- name: Cache Bazel
uses: actions/cache@v4
with:
path: |
~/.cache/bazel
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'MODULE.bazel') }}
restore-keys: |
${{ runner.os }}-bazel-
- name: Build //:tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}
run: |
bazelisk build --stamp --workspace_status_command="${PWD}/status.sh" //:tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}
path: bazel-bin/tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}_/tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}
Release:
needs: Build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set pre-release flag
id: release_type
run: |
if [[ ${{ github.ref }} == *beta* ]]; then
echo "type=pre-release" >> $GITHUB_OUTPUT
else
echo "type=release" >> $GITHUB_OUTPUT
fi
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ "${{ steps.release_type.outputs.type }}" == "pre-release" ]]; then
gh release create ${GITHUB_REF#refs/tags/} \
--title "Release ${GITHUB_REF#refs/tags/}" \
--prerelease \
--generate-notes
else
gh release create ${GITHUB_REF#refs/tags/} \
--title "Release ${GITHUB_REF#refs/tags/}" \
--generate-notes
fi
- name: Upload Release Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for artifact in tdiscuss-*; do
gh release upload ${GITHUB_REF#refs/tags/} $artifact/$artifact
done