forked from just-buildsystem/justbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (165 loc) · 6.61 KB
/
deploy.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Build and Deploy
on:
push:
branches:
- testing*
- github-ci*
jobs:
linux-x86_64:
name: Linux x86_64
if: "!contains(github.event.head_commit.message, '[skip-ci]') || (github.event_name == 'schedule')"
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute base commit
run: |
git fetch https://github.com/just-buildsystem/justbuild stable-1.4
BASE_COMMIT="$(git merge-base ${GITHUB_REF_NAME} FETCH_HEAD)"
echo "BASE_COMMIT=${BASE_COMMIT}" >> $GITHUB_ENV
- name: Restore local cache
uses: actions/cache/restore@v4
with:
path: ./work_static-x86_64/build/.just
key: deploy-${{ runner.os }}-x86_64
- name: Build TAR package
run: |
.github/make-pkg/docker-build.sh ${BASE_COMMIT} static-x86_64
cp ./work_static-x86_64/source/justbuild-*.tar.gz .
- name: Run garbage collector and clean cache
if: ${{ success() }}
run: |
docker run --rm -v $GITHUB_WORKSPACE:/workspace -w /workspace \
just-make-tar:static-x86_64 sh -c "\
just gc --local-build-root \$(pwd)/work_static-x86_64/build/.just"
gh extension install actions/gh-actions-cache
if [ -n "$(gh actions-cache list -R ${GITHUB_REPOSITORY} -B ${GITHUB_REF} --key 'deploy-${{ runner.os }}-x86_64')" ]; then
gh actions-cache delete "deploy-${{ runner.os }}-x86_64" -R ${GITHUB_REPOSITORY} -B ${GITHUB_REF} --confirm
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Store local cache
uses: actions/cache/save@v4
if: ${{ success() }}
with:
path: ./work_static-x86_64/build/.just
key: deploy-${{ runner.os }}-x86_64
- name: Build DEB package
run: |
.github/make-pkg/docker-build.sh ${BASE_COMMIT} bundled-deb
cp ./work_bundled-deb/source/justbuild_*.deb .
- name: Build RPM package
run: |
.github/make-pkg/docker-build.sh ${BASE_COMMIT} bundled-rpm
cp ./work_bundled-rpm/source/rpmbuild/RPMS/x86_64/justbuild-*.rpm .
- name: Collect packages
run: |
tar --sort=name --owner=root:0 --group=root:0 --mtime='UTC 1970-01-01' -czvf justbuild-x86_64-linux.tar.gz *.tar.gz *.deb *.rpm
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: justbuild-x86_64-linux
path: justbuild-x86_64-linux.tar.gz
retention-days: 1
linux-aarch64:
name: Linux aarch64
if: "!contains(github.event.head_commit.message, '[skip-ci]') || (github.event_name == 'schedule')"
runs-on: ubuntu-22.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compute base commit
run: |
git fetch https://github.com/just-buildsystem/justbuild stable-1.4
BASE_COMMIT="$(git merge-base ${GITHUB_REF_NAME} FETCH_HEAD)"
echo "BASE_COMMIT=${BASE_COMMIT}" >> $GITHUB_ENV
- name: Restore local cache
uses: actions/cache/restore@v4
with:
path: ./work_static-aarch64/build/.just
key: deploy-${{ runner.os }}-aarch64
- name: Build TAR package
run: |
.github/make-pkg/docker-build.sh ${BASE_COMMIT} static-aarch64
cp ./work_static-aarch64/source/justbuild-*.tar.gz .
- name: Run garbage collector and clean cache
if: ${{ success() }}
run: |
docker run --rm -v $GITHUB_WORKSPACE:/workspace -w /workspace \
just-make-tar:static-aarch64 sh -c "\
just gc --local-build-root \$(pwd)/work_static-x86_64/build/.just"
gh extension install actions/gh-actions-cache
if [ -n "$(gh actions-cache list -R ${GITHUB_REPOSITORY} -B ${GITHUB_REF} --key 'deploy-${{ runner.os }}-aarch64')" ]; then
gh actions-cache delete "deploy-${{ runner.os }}-aarch64" -R ${GITHUB_REPOSITORY} -B ${GITHUB_REF} --confirm
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Store local cache
uses: actions/cache/save@v4
if: ${{ success() }}
with:
path: ./work_static-aarch64/build/.just
key: deploy-${{ runner.os }}-aarch64
- name: Collect packages
run: |
tar --sort=name --owner=root:0 --group=root:0 --mtime='UTC 1970-01-01' -czvf justbuild-aarch64-linux.tar.gz *.tar.gz
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: justbuild-aarch64-linux
path: justbuild-aarch64-linux.tar.gz
retention-days: 1
deploy-packages:
name: Deploy Packages
if: "!contains(github.event.head_commit.message, '[skip-ci]') && (github.event_name != 'schedule')"
runs-on: ubuntu-22.04
needs: [linux-x86_64, linux-aarch64]
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve x86_64 Linux packages
uses: actions/download-artifact@v4
with:
name: justbuild-x86_64-linux
- name: Retrieve aarch64 Linux packages
uses: actions/download-artifact@v4
with:
name: justbuild-aarch64-linux
- name: Unpack retrieved archives
run: |
tar -xzvf justbuild-x86_64-linux.tar.gz
rm justbuild-x86_64-linux.tar.gz
tar -xzvf justbuild-aarch64-linux.tar.gz
rm justbuild-aarch64-linux.tar.gz
- name: Determine release info and create checksums
run: |
VERSION="$(ls *.tar.gz | sed -n 's/.*justbuild-\(.*\)-x86_64-linux.tar.gz/\1/p')"
UNTAGGED=$([[ "$VERSION" = *+* ]] && echo true || echo false)
TAG_NAME="v$(echo $VERSION | tr '~+' '-')"
echo "UNTAGGED=${UNTAGGED}" >> $GITHUB_ENV
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV
sha256sum *.tar.gz *.deb *.rpm | tee SHA256SUMS
- name: Upload package checksums
uses: actions/upload-artifact@v4
with:
name: SHA256SUMS
path: SHA256SUMS
if-no-files-found: error
- name: Upload package release
uses: xresloader/upload-to-github-release@v1
if: startsWith(github.ref, 'refs/heads/github-ci')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "*.tar.gz;*.deb;*.rpm;SHA256SUMS"
tag_name: ${{ env.TAG_NAME }}
prerelease: ${{ env.UNTAGGED }}
tags: false
draft: false
overwrite: true