-
-
Notifications
You must be signed in to change notification settings - Fork 2
176 lines (152 loc) Β· 6.38 KB
/
Copy pathrelease.yml
File metadata and controls
176 lines (152 loc) Β· 6.38 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Build and Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to build (e.g. 1.1.0)'
required: true
type: string
arch:
description: 'Architecture to build for'
required: true
default: 'All'
type: choice
options:
- All
- amd64
- aarch64
permissions:
contents: write
packages: write
jobs:
setup:
name: Setup Build Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
if [ "${{ github.event.inputs.arch }}" == "All" ]; then
echo 'matrix=["amd64", "aarch64"]' >> $GITHUB_OUTPUT
else
echo 'matrix=["${{ github.event.inputs.arch }}"]' >> $GITHUB_OUTPUT
fi
notify_workflow:
name: Notify Build Start
runs-on: ubuntu-latest
steps:
- name: Send Telegram Notification
run: |
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-F chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \
-F message_thread_id="${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }}" \
-F text="
π *Build started for Aesir!*
π¦ *Repository:* [${{ github.repository }}](https://github.com/${{ github.repository }})
ποΈ *Branch:* \`${{ github.ref_name }}\`
ποΈ *Version:* \`${{ github.event.inputs.version }}\`
π₯οΈ *Architectures:* \`${{ github.event.inputs.arch }}\`
βοΈ *Commit:* [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
[π View GitHub Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" \
-F parse_mode="Markdown"
build-and-release:
name: Build and Release
runs-on: ubuntu-latest
needs: notify_workflow
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Make build script executable
run: chmod +x build.sh
- name: Build project
run: ./build.sh
- name: Verify build output amd64
if: github.event.inputs.arch == 'All' || github.event.inputs.arch == 'amd64'
run: |
if [ ! -f "bin/Release/net10.0/publish/linux-x64/Aesir" ]; then
echo "Build output not found for amd64!"
exit 1
fi
chmod +x bin/Release/net10.0/publish/linux-x64/Aesir
- name: Verify build output arm64
if: github.event.inputs.arch == 'All' || github.event.inputs.arch == 'aarch64'
run: |
if [ ! -f "bin/Release/net10.0/publish/linux-arm64/Aesir" ]; then
echo "Build output not found for arm64!"
exit 1
fi
chmod +x bin/Release/net10.0/publish/linux-arm64/Aesir
- name: Extract Latest Changelog
id: changelog
run: |
# Extract the section for the latest release (everything between the first and second '# [')
awk '/^# \[/ {if (p) exit; p=1; next} p' CHANGELOG.md > latest_changelog.txt
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
cat latest_changelog.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create v${{ github.event.inputs.version }} \
--title "Aesir v${{ github.event.inputs.version }}" \
--notes "${{ steps.changelog.outputs.CHANGELOG }}" \
--target ${{ github.ref_name }}
- name: Prepare release assets
run: |
if [ -f "bin/Release/net10.0/publish/linux-x64/Aesir" ]; then
cp bin/Release/net10.0/publish/linux-x64/Aesir Aesir-linux-amd64
fi
if [ -f "bin/Release/net10.0/publish/linux-arm64/Aesir" ]; then
cp bin/Release/net10.0/publish/linux-arm64/Aesir Aesir-linux-aarch64
fi
- name: Upload release asset amd64
if: github.event.inputs.arch == 'All' || github.event.inputs.arch == 'amd64'
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload v${{ github.event.inputs.version }} Aesir-linux-amd64 --clobber
- name: Upload release asset arm64
if: github.event.inputs.arch == 'All' || github.event.inputs.arch == 'aarch64'
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload v${{ github.event.inputs.version }} Aesir-linux-aarch64 --clobber
notify_completion:
name: Notify Build Completion
needs: [setup, build-and-release, notify_workflow]
runs-on: ubuntu-latest
if: always() && (needs.build-and-release.result != 'cancelled')
steps:
- name: Determine build results
id: results
run: |
# Check the overall result of the build-and-release job
if [ "${{ needs.build-and-release.result }}" == "success" ]; then
echo "status=β
Build & Release completed successfully!" >> $GITHUB_OUTPUT
echo "emoji=π" >> $GITHUB_OUTPUT
else
echo "status=β Build & Release failed!" >> $GITHUB_OUTPUT
echo "emoji=π₯" >> $GITHUB_OUTPUT
fi
- name: Send Telegram Completion Notification
run: |
DATE=$(date +'%Y-%m-%d')
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
-F chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \
-F message_thread_id="${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }}" \
-F text="
${{ steps.results.outputs.emoji }} *Aesir Workflow Finished*
π¦ *Repository:* [${{ github.repository }}](https://github.com/${{ github.repository }})
π
*Date:* $DATE
π·οΈ *Version:* \`v${{ github.event.inputs.version }}\`
π *Status:* ${{ steps.results.outputs.status }}
πΎ *Download releases:* [GitHub Releases](https://github.com/${{ github.repository }}/releases/tag/v${{ github.event.inputs.version }})
[π View GitHub Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" \
-F parse_mode="Markdown"