-
Notifications
You must be signed in to change notification settings - Fork 490
126 lines (109 loc) · 4.31 KB
/
build-staging.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 + Release | Staging
on:
push:
branches:
- 'staging'
jobs:
test:
runs-on: ubuntu-latest
# Only run if the commit message contains the string [build]
if: contains(github.event.head_commit.message, '[build]')
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Unit and integration tests
run: dotnet test
build:
runs-on: ubuntu-latest
needs: test
steps:
# Checkout the repository
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Get the commit number
- name: Get commit number
run: echo "COMMIT_NUMBER=$(git rev-list --count HEAD)" >> $GITHUB_ENV
# Read the version
- name: Read version
run: echo "VERSION=$(head -n 1 OpenBullet2.Web/version.txt)" >> $GITHUB_ENV
# Overwrite the contents of version.txt with $VERSION.$COMMIT_NUMBER
- name: Append commit number to version.txt
run: echo "${{ env.VERSION }}.${{ env.COMMIT_NUMBER }}" > OpenBullet2.Web/version.txt
# Do the same for the native client
- name: Append commit number to version.txt
run: echo "${{ env.VERSION }}.${{ env.COMMIT_NUMBER }}" > OpenBullet2.Native/version.txt
# Get the commit description
- name: Get commit description
run: |
echo 'COMMIT_DESCRIPTION<<EOF' >> $GITHUB_ENV
git log -1 --pretty=%b >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
# Read the version
- name: Read version again
run: echo "VERSION=$(head -n 1 OpenBullet2.Web/version.txt)" >> $GITHUB_ENV
# Build using docker
- name: Build using docker
run: docker build -t openbullet2-build -f Dockerfile.build .
# Extract files from the /app folder of the image into a zip
- name: Extract files from the image
run: |
docker run --name openbullet2-extract openbullet2-build echo "Extracting files"
docker cp openbullet2-extract:/app/web .web
docker cp openbullet2-extract:/app/native .native
docker cp openbullet2-extract:/app/updater .updater
docker rm openbullet2-extract
mkdir .release
cd .web
zip -r ../.release/OpenBullet2.Web.zip ./*
cd ../.native
zip -r ../.release/OpenBullet2.Native.zip ./*
cd ..
mv .updater/web/win-x64/OpenBullet2.Web.Updater.exe .release/ob2-web-updater-win-x64.exe
mv .updater/web/win-x86/OpenBullet2.Web.Updater.exe .release/ob2-web-updater-win-x86.exe
mv .updater/web/win-arm64/OpenBullet2.Web.Updater.exe .release/ob2-web-updater-win-arm64.exe
mv .updater/web/linux-x64/OpenBullet2.Web.Updater .release/ob2-web-updater-linux-x64
mv .updater/web/linux-arm64/OpenBullet2.Web.Updater .release/ob2-web-updater-linux-arm64
mv .updater/native/win-x64/OpenBullet2.Native.Updater.exe .release/ob2-native-updater-win-x64.exe
mv .updater/native/win-x86/OpenBullet2.Native.Updater.exe .release/ob2-native-updater-win-x86.exe
mv .updater/native/win-arm64/OpenBullet2.Native.Updater.exe .release/ob2-native-updater-win-arm64.exe
# Upload the files to the release
- name: Upload OpenBullet2 release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: '.release/*'
file_glob: true
release_name: ${{ env.VERSION }}
tag: ${{ env.VERSION }}
overwrite: false
prerelease: true
make_latest: true
# Show ONLY the commit description in the release (without)
body: |
This is a **STAGING** build. It might be unstable. Use at your own discretion.
Changelog:
${{ env.COMMIT_DESCRIPTION }}
- name: Notify new build on discord
if: success()
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: |
[
{
"title": "New staging build",
"description": "Staging release **${{ env.VERSION }}** available",
"color": 5763719
}
]
uses: Ilshidur/action-discord@master
- name: Setup upterm session
uses: lhotari/action-upterm@v1
if: ${{ failure() }}
with:
## If no one connects after 5 minutes, shut down server.
wait-timeout-minutes: 5