-
Notifications
You must be signed in to change notification settings - Fork 7
168 lines (148 loc) · 5.48 KB
/
release.yml
File metadata and controls
168 lines (148 loc) · 5.48 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
name: Release
on:
schedule:
- cron: "0 0 * * *" # Every day at midnight
workflow_dispatch:
inputs:
bun-versions:
description: "Bun version, comma separated (e.g. 0.0.1,0.0.2,1.0.8-canary.20231104.1)"
required: false
default: ""
nodejs-version:
description: "Node.js version, comma separated (e.g. 14.7.4,17.3.8,18.4.5)"
required: false
default: ""
distros:
description: "Distro, comma separated (e.g. alpine,debian-slim,debian)"
required: false
default: ""
# TODO: To be implemented
# skip-check:
# description: "Skip version check"
# required: false
# default: "true"
env:
REGISTRY: imbios
PLATFORMS: linux/amd64,linux/arm64
NODE_MAJOR_VERSIONS_TO_CHECK: 20,22,24,25
NODE_VERSIONS_TO_BUILD: ""
BUN_TAGS_TO_CHECK: canary,latest
BUN_VERSIONS_TO_BUILD: ""
DISTROS: alpine,debian-slim,debian
jobs:
# TODO: To be implemented
# test-job:
# uses: ./.github/workflows/ci.yml
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v1
- name: Download versions.json
run: gh release download versions -p versions.json || echo "{}" > versions.json
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cleanup unsupported versions
run: |
bun run check-bun-node.ts --cleanup --generate
if [[ `git status --porcelain` ]]; then
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "chore: cleanup unsupported versions"
git push
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate Matrix
id: set-matrix
run: |
MATRIX=$(bun run check-bun-node.ts --matrix)
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
env:
BUN_TAGS_TO_CHECK: ${{ env.BUN_TAGS_TO_CHECK }}
DISTROS: ${{ env.DISTROS }}
NODE_MAJOR_VERSIONS_TO_CHECK: ${{ env.NODE_MAJOR_VERSIONS_TO_CHECK }}
build:
needs: setup
runs-on: ubuntu-latest
if: ${{ fromJson(needs.setup.outputs.matrix).include[0] }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- uses: actions/checkout@v5
- name: Download versions.json
run: gh release download versions -p versions.json || echo "{}" > versions.json
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08
name: Build and push Docker images
with:
timeout_minutes: 120
max_attempts: 3
retry_on: error
command: ./build_single.sh --bun "${{ matrix.bun_version }}" --node "${{ matrix.node_version }}" --distro "${{ matrix.distro }}"
env:
REGISTRY: ${{ env.REGISTRY }}
PLATFORMS: ${{ env.PLATFORMS }}
- name: Upload success artifact
uses: actions/upload-artifact@v4
with:
name: build-success-${{ matrix.bun_version }}-${{ matrix.node_version }}-${{ matrix.distro }}
path: build_success.json
update-release:
needs: build
runs-on: ubuntu-latest
if: always() && needs.build.result == 'success'
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v1
- name: Download versions.json
run: gh release download versions -p versions.json || echo "{}" > versions.json
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: build-success-*
merge-multiple: true
path: updates
- name: Update versions.json
run: |
# Merge all JSON fragments into versions.json
# We iterate over all files in updates/ and merge them using jq
# Note: This is a simple merge. If multiple builds update the same key, last one wins (which is fine as they should be identical for the same version).
for file in updates/*.json; do
if [ -f "$file" ]; then
# Merge nodejs versions
# We need to be careful not to overwrite the whole object if we only have partial updates.
# jq's * operator merges objects recursively.
jq -s '.[0] * .[1]' versions.json "$file" > versions.json.tmp && mv versions.json.tmp versions.json
fi
done
cat versions.json
- name: Upload versions.json
run: |
gh release create versions versions.json --title "Versions State" --notes "Stores the current versions.json state" || \
gh release upload versions versions.json --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
rerun-failed-jobs:
runs-on: ubuntu-latest
needs: [build]
if: failure()
steps:
- name: Rerun failed jobs in the current workflow
env:
GH_TOKEN: ${{ github.token }}
run: gh run rerun ${{ github.run_id }} --repo ${{ github.repository }} --failed