-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (111 loc) · 4.13 KB
/
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Build, Tag, and Release Application
on:
push:
tags:
- 'v*.*.*-*'
jobs:
build_and_release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.23.4'
- name: Cache Go Modules
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/.go/pkg/mod
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.mod') }}
restore-keys: |
${{ runner.os }}-go-mod-
- name: Build for GitHub Actions
env:
PRIVATE_GPG_KEY_GIST_URL: ${{ secrets.PRIVATE_GPG_KEY_GIST_URL }}
PRIVATE_PGP_KEY_PASSPHRASE: ${{ secrets.PRIVATE_PGP_KEY_PASSPHRASE }}
run: |
set -e # Exit immediately if any command fails
if [ -z "$PRIVATE_GPG_KEY_GIST_URL" ]; then
echo "Error: PRIVATE_GPG_KEY_GIST_URL is empty or not set."
exit 1
fi
if [ -z "$PRIVATE_PGP_KEY_PASSPHRASE" ]; then
echo "Error: PRIVATE_PGP_KEY_PASSPHRASE is empty or not set."
exit 1
fi
curl -s "$PRIVATE_GPG_KEY_GIST_URL" -o crypto/privkey.pem
if [ ! -s crypto/privkey.pem ]; then
echo "Error: Failed to download the private GPG key from the Gist."
exit 1
fi
echo "$PRIVATE_PGP_KEY_PASSPHRASE" > crypto/passphrase.txt
tr -d '\n' < crypto/passphrase.txt > tmp
mv tmp crypto/passphrase.txt
make build_gh_actions
rm -f crypto/privkey.pem crypto/passphrase.txt
- name: Get Version from Makefile
id: get_version
run: |
VERSION=$(make -s version | grep 'Version:' | awk '{print $2}')
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Create or Update Git Tag
id: create_tag
uses: rickstaa/[email protected]
with:
tag: ${{ env.VERSION }}
message: "Release ${{ env.VERSION }}"
force_push_tag: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
body: |
A new release of the application is now available.
- Version: ${{ env.VERSION }}
draft: false
prerelease: ${{ secrets.PRE_RELEASE == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Linux AMD64 Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ksau-go-linux-amd64
asset_name: ksau-go-linux-amd64
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Windows AMD64 Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ksau-go-windows-amd64.exe
asset_name: ksau-go-windows-amd64.exe
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Linux ARM64 Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ksau-go-linux-arm64
asset_name: ksau-go-linux-arm64
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Android ARM64 Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ksau-go-android-arm64
asset_name: ksau-go-android-arm64
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}