-
Notifications
You must be signed in to change notification settings - Fork 2
138 lines (118 loc) · 3.94 KB
/
dev.yml
File metadata and controls
138 lines (118 loc) · 3.94 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
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
name: Build Dev
on:
workflow_dispatch:
push:
branches:
- "dev"
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
COMMIT_ID: "${{ github.sha }}"
NAME: MacArthurGo
CGO_ENABLED: 0
jobs:
Build:
name: Build binary CI
runs-on: ubuntu-latest
strategy:
matrix:
goos: [ linux, windows, darwin, android ]
goarch: [ "386", amd64, arm64 ]
exclude:
- goos: darwin
goarch: "386"
- goos: android
goarch: "386"
- goos: android
goarch: amd64
steps:
- uses: actions/checkout@v5
- name: Set Environment
run: |
mkdir -p bin
echo "SHASHORT=$(git rev-parse --short "${{ env.COMMIT_ID }}")" >> "$GITHUB_ENV"
echo "BUILDTIME=$(date +'%Y-%m-%dT%H:%M:%SZ' -u)" >> $GITHUB_ENV
- name: Set LDFLAGS
run: |
echo "LDFLAGS=-w -s -X 'MacArthurGo/base.Version=${SHASHORT}' -X 'MacArthurGo/base.Branch=Beta/dev' -X 'MacArthurGo/base.BuildTime=${{ env.BUILDTIME }}'" >> $GITHUB_ENV
- name: Setup UPX
run: |
cd ..
wget https://github.com/upx/upx/releases/download/v4.2.2/upx-4.2.2-amd64_linux.tar.xz
tar xf upx-4.2.2-amd64_linux.tar.xz
echo "upx=../upx-4.2.2-amd64_linux/upx" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v5
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
go build -ldflags="${LDFLAGS}" -o bin/${{ env.NAME }}-${{ matrix.goos }}-${{ matrix.goarch }} ./
chmod +x bin/${{ env.NAME }}-*
- name: Rename Windows
if: ${{ matrix.goos == 'windows' }}
run: |
mv MacArthurGo-windows-${{ matrix.goarch }} MacArthurGo-windows-${{ matrix.goarch }}.exe
working-directory: bin
- name: UPX Compress
if: ${{ matrix.goos != 'darwin' }}
run: |
if [ ${{ matrix.goos }} != "windows" ] && [ ${{ matrix.goarch }} != "arm64" ]; then ${{ env.upx }} --lzma --best bin/${{ env.NAME }}-*; fi
- name: Upload To Artifact
if: ${{ success() }}
uses: actions/upload-artifact@main
with:
name: ${{ matrix.goos }}-${{ matrix.goarch }}-${{ env.SHASHORT }}
path: |
bin/*
Upload-Prerelease:
permissions: write-all
needs: [Build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@main
with:
path: bin/
- name: Display structure of downloaded files
run: ls -R
working-directory: bin
- name: Delete current release assets
uses: 8Mi-Tech/delete-release-assets-action@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: Prerelease-${{ github.ref_name }}
deleteOnlyFromDrafts: false
- name: Set Env
run: |
echo "UPLOADTIME=$(date +'%Y-%m-%dT%H:%M:%SZ' -u)" >> $GITHUB_ENV
shell: bash
- name: Tag Repo
uses: richardsimko/update-tag@v1.1.6
with:
tag_name: Prerelease-${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
cat > release.txt << 'EOF'
Release created at ${{ env.UPLOADTIME }}
Commit: ${{ env.COMMIT_ID }}
Synchronize ${{ github.ref_name }} branch code updates, keeping only the latest version
EOF
- run: |
cat > version.json << 'EOF'
{"version": "${{ env.COMMIT_ID }}", "upload_time": "${{ env.UPLOADTIME }}"}
EOF
working-directory: bin
- name: Upload Prerelease
uses: softprops/action-gh-release@v2
if: ${{ success() }}
with:
tag_name: Prerelease-${{ github.ref_name }}
files: |
bin/*
bin/*/*
prerelease: true
generate_release_notes: true
body_path: release.txt