-
Notifications
You must be signed in to change notification settings - Fork 4
204 lines (180 loc) · 7.39 KB
/
main.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
192
193
194
195
196
197
198
199
200
201
202
203
204
name: MAIN
on:
push:
branches:
- main
repository_dispatch:
types: [build-from-punq-frontend]
env:
IMAGE_NAME: ghcr.io/mogenius/punq
DOCKERFILE: Dockerfile-Operator
VERSION:
HOME: /root
jobs:
prepare:
runs-on: [self-hosted, X64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Sematic Release Version
shell: bash -ieo pipefail {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --system http.sslVerify false
git config --global user.email "[email protected]"
git config --global user.name "punq"
git config --global credential.helper cache
semantic-release
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "VERSION=$VERSION" >> $GITHUB_ENV
COMMIT_HASH=$(git rev-parse --short HEAD)
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_ENV
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
BUILD_TIMESTAMP=$(date)
echo "BUILD_TIMESTAMP=$BUILD_TIMESTAMP" >> $GITHUB_ENV
- name: download and inject punq-frontend
run: |
curl https://github.com/mogenius/punq-frontend/releases/download/latest/latest.tar.gz -L -o ui.tar.gz
mkdir -p ui/dist
tar -xzf ui.tar.gz -C ui/dist
- name: Authenticate GitHub CLI
run: gh auth login --with-token <<< "${{ secrets.PUNQ_TOKEN }}"
- name: Execute make all
shell: bash -ieo pipefail {0}
run: |
make all
- name: Upload binaries
run: |
ls -lisa builds
for build in builds/*; do
gh release upload ${{ env.VERSION }} "$build" --repo mogenius/punq
done
env:
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }}
- name: Create release in another repo
run: |
gh release create refs/tags/${{ env.VERSION }} --title "Release ${{ env.VERSION }}" --repo mogenius/homebrew-punq
env:
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }}
- name: Package artefacts
run: |
for file in builds/*; do
tar -czvf builds/$(basename "$file").tar.gz -C builds $(basename "$file")
done
ls -lisa builds
- name: Upload tarballs
run: |
ls -lisa builds
for tarball in builds/*.tar.gz; do
gh release upload ${{ env.VERSION }} "$tarball" --repo mogenius/homebrew-punq
done
env:
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }}
- name: UPDATE BREW
run: |
./release.sh
git clone https://${{secrets.PUNQ_TOKEN}}@github.com/mogenius/homebrew-punq
cd homebrew-punq
cp ../punq.rb .
git add punq.rb
git commit -m "[skip ci] ${{ env.VERSION }}"
git push
env:
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }}
- name: UPDATE SCOOP
run: |
git add punq.json
git commit -m "[skip ci] scoop ${{ env.VERSION }}"
git push
env:
GH_TOKEN: ${{ secrets.PUNQ_TOKEN }}
build-amd64:
needs: prepare
runs-on: [self-hosted, X64]
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PUNQ_TOKEN }}
- name: download and inject punq-frontend
run: |
curl https://github.com/mogenius/punq-frontend/releases/download/latest/latest.tar.gz -L -o ui.tar.gz
mkdir -p ui/dist
tar -xzf ui.tar.gz -C ui/dist
- name: Build and push AMD64 image
run: |
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "VERSION=$VERSION" >> $GITHUB_ENV
GIT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2 | tr '[:upper:]' '[:lower:]')
COMMIT_HASH=$(git rev-parse --short HEAD)
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
BUILD_TIMESTAMP=$(date -Iseconds)
OPERATOR_IMAGE="${{ env.IMAGE_NAME }}:$VERSION"
docker build -f ${{ env.DOCKERFILE }} --build-arg GOOS=linux --build-arg GOARCH=amd64 --build-arg VERSION="$VERSION" --build-arg OPERATOR_IMAGE="$OPERATOR_IMAGE" --build-arg BUILD_TIMESTAMP="$BUILD_TIMESTAMP" --build-arg GIT_BRANCH="$GIT_BRANCH" --build-arg COMMIT_HASH="$COMMIT_HASH" -t ${{ env.IMAGE_NAME }}:$VERSION-amd64 -t ${{ env.IMAGE_NAME }}:latest-amd64 .
docker push ${{ env.IMAGE_NAME }}:$VERSION-amd64
build-arm64-linux:
needs: prepare
runs-on: [self-hosted, ARM64]
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PUNQ_TOKEN }}
- name: download and inject punq-frontend
run: |
curl https://github.com/mogenius/punq-frontend/releases/download/latest/latest.tar.gz -L -o ui.tar.gz
mkdir -p ui/dist
tar -xzf ui.tar.gz -C ui/dist
- name: Build and push ARM64-linux image
run: |
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "VERSION=$VERSION" >> $GITHUB_ENV
GIT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2 | tr '[:upper:]' '[:lower:]')
COMMIT_HASH=$(git rev-parse --short HEAD)
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
BUILD_TIMESTAMP=$(date -Iseconds)
OPERATOR_IMAGE="${{ env.IMAGE_NAME }}:$VERSION"
docker build --platform=linux/arm64 -f ${{ env.DOCKERFILE }} --build-arg GOOS=linux --build-arg GOARCH=arm64 --build-arg VERSION="$VERSION" --build-arg OPERATOR_IMAGE="$OPERATOR_IMAGE" --build-arg BUILD_TIMESTAMP="$BUILD_TIMESTAMP" --build-arg GIT_BRANCH="$GIT_BRANCH" --build-arg COMMIT_HASH="$COMMIT_HASH" -t ${{ env.IMAGE_NAME }}:$VERSION-arm64-linux -t ${{ env.IMAGE_NAME }}:latest-arm64-linux .
docker push ${{ env.IMAGE_NAME }}:$VERSION-arm64-linux
merge-images:
needs: [build-amd64, build-arm64-linux, prepare]
runs-on: self-hosted
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.PUNQ_TOKEN }}
- name: Merge images into a multi-arch manifest
run: |
VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "VERSION=$VERSION" >> $GITHUB_ENV
docker manifest create ${{ env.IMAGE_NAME }}:$VERSION \
--amend ${{ env.IMAGE_NAME }}:$VERSION-amd64 \
--amend ${{ env.IMAGE_NAME }}:$VERSION-arm64-linux
docker manifest push ${{ env.IMAGE_NAME }}:$VERSION
docker manifest create ${{ env.IMAGE_NAME }}:latest \
--amend ${{ env.IMAGE_NAME }}:$VERSION-amd64 \
--amend ${{ env.IMAGE_NAME }}:$VERSION-arm64-linux
docker manifest push ${{ env.IMAGE_NAME }}:latest