-
Notifications
You must be signed in to change notification settings - Fork 80
161 lines (146 loc) · 5.07 KB
/
build.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
158
159
160
161
name: Build AltServer
on:
push:
workflow_dispatch:
inputs:
sync_upstream:
required: false
default: false
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
repository_dispatch:
schedule:
- cron: "0 */4 * * *" # min hour day week year
env:
REGISTRY: ghcr.io
jobs:
check:
runs-on: ubuntu-latest
name: "Check Upstream Updates"
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Check If Need Checking
id: needCheck
if: ${{ github.event_name == 'schedule' || ( github.event_name == 'workflow_dispatch' && github.event.inputs.sync_upstream ) }}
run: |
echo "needCheck=1" >> $GITHUB_ENV
- name: Check Upstream Version
id: check
run: |
if [[ "$needCheck" == 1 ]]; then
echo "Checking changes in upstream_repo..."
current_upstream=$(git ls-tree HEAD upstream_repo | awk '{ print $3 }')
echo "Current Upstream Commit: $current_upstream"
git submodule update --remote -- upstream_repo
new_upstream=$( cd upstream_repo; git show -s --format=%H )
echo "New Upstream Commit: $new_upstream"
git reset --hard
git submodule update --init
if [[ "$current_upstream" != "$new_upstream" ]]; then
echo "Upstream got new commits, go updating!"
echo "::set-output name=updated::1"
else
echo "Upstream no change~"
echo "::set-output name=updated::0"
fi
else
echo "Needn't to check changes, directly return~"
echo "::set-output name=updated::0"
fi
- uses: gautamkrishnar/keepalive-workflow@master
with:
commit_message: "[proj] keepalive-workflow auto commit"
outputs:
updated: ${{ steps.check.outputs.updated }}
build:
needs: [check]
strategy:
matrix:
builder: [ghcr.io/nyamisty/altserver_builder_alpine_armv7, ghcr.io/nyamisty/altserver_builder_alpine_aarch64, ghcr.io/nyamisty/altserver_builder_alpine_amd64, ghcr.io/nyamisty/altserver_builder_alpine_i386]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Do Submodule Update
if: ${{ needs.check.outputs.updated == '1' }}
run:
git submodule update --remote -- upstream_repo
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare build
run: mkdir /tmp/build_output
- name: Build
run: |
image=${{ matrix.builder }}
docker pull $image
docker run -v ${PWD}:/workdir -w /workdir $image bash -c 'mkdir build; cd build; make -f ../Makefile -j3'
cp build/AltServer-* /tmp/build_output; chmod +x /tmp/build_output/*
sudo rm -rf build
git clean -fdX
- name: Upload to github artifact
uses: NyaMisty/upload-artifact-as-is@master
with:
path: /tmp/build_output
release:
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs: [build]
name: "release"
steps:
- name: "Create artifact directory"
run: |
mkdir -p build_output
- name: "Download all artifacts"
uses: actions/download-artifact@v2
with:
path: build_output
- name: "Rearrange artifacts"
run: |
find build_output
mkdir -p build_release
mv build_output/*/* build_release
ls build_release
if [ "$(ls -A build_release)" ]; then exit 0; else exit 1; fi
- name: Release
uses: softprops/action-gh-release@v1
with:
files: build_release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update_submodule:
runs-on: ubuntu-latest
needs: [check, build]
if: ${{ needs.check.outputs.updated == '1' }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: recursive
- name: Commit Submodule Update
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git submodule update --remote -- upstream_repo
git commit -m "[server] Sync Upstream Repo commit" upstream_repo
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}