-
Notifications
You must be signed in to change notification settings - Fork 1
158 lines (142 loc) · 6.19 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
on:
push:
tags:
- 'v*'
name: Create Release
jobs:
once:
name: Create single release for all builds
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create a release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
build:
name: Build and package for all platforms
needs: once
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
arch: [amd64, arm64, arm64-android, arm7]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Build and package for Android
if: matrix.arch == 'arm64-android' && matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y lib32stdc++6 lib32z1
wget https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip
export ANDROID_HOME=$HOME/android
mkdir -p $ANDROID_HOME/cmdline-tools
unzip commandlinetools-linux-9477386_latest.zip -d /tmp
mv /tmp/cmdline-tools $ANDROID_HOME/cmdline-tools/latest
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "platform-tools" "ndk-bundle" "platforms;android-21"
export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle
export PATH=$ANDROID_NDK_HOME:$PATH
export GOARCH=arm64
export CGO_ENABLED=1
export GOOS=android
find $ANDROID_HOME -name aarch64-linux-android21-clang
export CC=`find $ANDROID_HOME -name aarch64-linux-android21-clang | head -1`
go build -v -o audioloader server.go 2>&1 | tee build.log
tar -czvf audioloader-linux-arm64-android-${{ github.ref_name }}.tar.gz audioloader static
- name: Build and package for Linux and Android
if: matrix.os == 'ubuntu-latest'
run: |
if [[ "${{ matrix.arch }}" == "amd64" ]]; then
export GOARCH=amd64
export GOOS=linux
export CGO_ENABLED=0
go build -v -o audioloader server.go
tar -czvf audioloader-linux-amd64-${{ github.ref_name }}.tar.gz audioloader static
elif [[ "${{ matrix.arch }}" == "arm64" ]]; then
export GOARCH=arm64
export GOOS=linux
export CGO_ENABLED=0
go build -v -o audioloader server.go
tar -czvf audioloader-linux-arm64-${{ github.ref_name }}.tar.gz audioloader static
elif [[ "${{ matrix.arch }}" == "arm7" ]]; then
export GOARCH=arm
export GOOS=linux
export GOARM=7
export CGO_ENABLED=0
go build -v -o audioloader server.go
tar -czvf audioloader-linux-arm7-${{ github.ref_name }}.tar.gz audioloader static
fi
- name: Build and package for Windows
if: matrix.os == 'windows-latest' && matrix.arch == 'amd64'
run: |
cmd /C "set CGO_ENABLED=0 && go build -v -o audioloader.exe server.go"
powershell Compress-Archive -Path audioloader.exe,static -DestinationPath audioloader-windows-x86_64-${{ github.ref_name }}.zip
- name: Upload Release Asset Linux amd64
if: matrix.arch == 'amd64' && matrix.os == 'ubuntu-latest'
id: upload-release-asset-linux-amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ needs.once.outputs.upload_url }}
asset_path: ./audioloader-linux-amd64-${{ github.ref_name }}.tar.gz
asset_name: audioloader-linux-amd64-${{ github.ref_name }}.tar.gz
asset_content_type: application/x-tgz
- name: Upload Release Asset Linux arm64
if: matrix.arch == 'arm64' && matrix.os == 'ubuntu-latest'
id: upload-release-asset-linux-arm64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ needs.once.outputs.upload_url }}
asset_path: ./audioloader-linux-arm64-${{ github.ref_name }}.tar.gz
asset_name: audioloader-linux-arm64-${{ github.ref_name }}.tar.gz
asset_content_type: application/x-tgz
- name: Upload Release Asset Linux arm64-android
if: matrix.arch == 'arm64-android' && matrix.os == 'ubuntu-latest'
id: upload-release-asset-linux-arm64-android
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ needs.once.outputs.upload_url }}
asset_path: ./audioloader-linux-arm64-android-${{ github.ref_name }}.tar.gz
asset_name: audioloader-linux-arm64-android-${{ github.ref_name }}.tar.gz
asset_content_type: application/x-tgz
- name: Upload Release Asset Linux arm7
if: matrix.arch == 'arm7' && matrix.os == 'ubuntu-latest'
id: upload-release-asset-linux-arm7
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ needs.once.outputs.upload_url }}
asset_path: ./audioloader-linux-arm7-${{ github.ref_name }}.tar.gz
asset_name: audioloader-linux-arm7-${{ github.ref_name }}.tar.gz
asset_content_type: application/x-tgz
- name: Upload Release Asset Windows amd64
if: matrix.os == 'windows-latest' && matrix.arch == 'amd64'
id: upload-release-asset-windows-amd64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ needs.once.outputs.upload_url }}
asset_path: ./audioloader-windows-x86_64-${{ github.ref_name }}.zip
asset_name: audioloader-windows-x86_64-${{ github.ref_name }}.zip
asset_content_type: application/zip