-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (59 loc) · 2.16 KB
/
release.yml
File metadata and controls
69 lines (59 loc) · 2.16 KB
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
# .github/workflows/release.yaml
name: Build and release Go Project
on:
release:
types: [created]
jobs:
release-linux-amd64:
name: release linux/amd64
runs-on: ubuntu-latest
permissions: write-all
strategy:
matrix:
# List of GOOS and GOARCH pairs from `go tool dist list`
goosarch:
- 'linux/ppc64le'
- 'linux/amd64'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6 # Recommended action to set up Go environment
with:
go-version-file: 'go.mod' # Automatically detects the Go version from go.mod
- name: Get OS and arch info
run: |
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
REPO=${{github.repository}}
BINARY_NAME=${REPO#*/}-$GOOS-$GOARCH
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
- name: Set version variable
run: echo "PROGRAM_VERSION="$(git describe --always --long --dirty) >> ${GITHUB_ENV}
- name: Set release variable
run: echo "PROGRAM_RELEASE="$(git describe --tags --abbrev=0) >> ${GITHUB_ENV}
- name: Build project
run: go build -ldflags="-X main.version=$(git describe --always --long --dirty) -X main.release=$(git describe --tags --abbrev=0)" -o "$BINARY_NAME" *.go
- name: Release binaries
uses: softprops/action-gh-release@v3
# https://github.com/softprops/action-gh-release
with:
files: |
${{ env.BINARY_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided secret
- name: Release scripts
uses: softprops/action-gh-release@v3
# https://github.com/softprops/action-gh-release
if: ${{ env.GOARCH == 'amd64' }}
# https://docs.github.com/en/actions/reference/workflows-and-actions/expressions
with:
files: |
scripts/create-cluster.sh
scripts/delete-cluster.sh
scripts/console.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided secret