Repository navigation
203 lines (185 loc) · 10.2 KB
/
Copy pathpush-github.yml
File metadata and controls
203 lines (185 loc) · 10.2 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
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
name: Push on GitHub (REUSABLE)
permissions:
contents: write
discussions: write
actions: read
on:
workflow_call:
outputs:
manifest_sha256:
description: Manifest hash accepted by the create-only release claim
value: ${{ jobs.build.outputs.manifest_sha256 }}
inputs:
VERSION:
required: true
type: string
PRERELEASE:
required: true
type: boolean
MANIFEST_SHA256:
required: false
type: string
default: ""
jobs:
build:
name: Publish GitHub release
runs-on: ubuntu-26.04
timeout-minutes: 30
outputs:
manifest_sha256: ${{ steps.claim.outputs.manifest_sha256 }}
steps:
# Checkout
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Download release manifest
if: inputs.VERSION != 'testing'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: release-manifest
- name: Verify release manifest
if: inputs.VERSION != 'testing'
env:
MANIFEST_SHA256: ${{ inputs.MANIFEST_SHA256 }}
run: python3 .github/scripts/release_artifacts.py verify
# Pin the install script default to the testing channel before checksum/upload,
# so a script downloaded from the Testing release defaults to the testing version
# instead of the hardcoded stable one. Must run BEFORE the checksum step.
- name: Pin install script default to testing
if: inputs.VERSION == 'testing'
run: |
# Fail loudly if the declaration is missing or duplicated, so a future
# refactor cannot let sed silently rewrite the wrong/extra line.
count=$(grep -cE '^DEFAULT_BUNKERWEB_VERSION="' misc/install-bunkerweb.sh)
[ "$count" = "1" ] || { echo "expected exactly 1 DEFAULT_BUNKERWEB_VERSION line, found $count"; exit 1; }
sed -i -E 's/^DEFAULT_BUNKERWEB_VERSION=".*"/DEFAULT_BUNKERWEB_VERSION="testing"/' misc/install-bunkerweb.sh
grep -q '^DEFAULT_BUNKERWEB_VERSION="testing"$' misc/install-bunkerweb.sh
# Generate checksum for install script
- name: Generate checksum for install script
run: |
cd misc
sha256sum install-bunkerweb.sh > install-bunkerweb.sh.sha256
# Get PDF doc
- name: Get documentation
if: inputs.VERSION != 'testing'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: BunkerWeb_documentation_v${{ inputs.VERSION }}.pdf
# Sanitize version (replace ~ with - for valid Git tag names)
- name: Sanitize version
id: sanitize
run: |
VERSION="${{ inputs.VERSION }}"
echo "version=${VERSION//\~/-}" >> "$GITHUB_OUTPUT"
# Create tag. Versioned releases are TRIGGERED by their tag, so it
# already exists; only the rolling `testing` tag is minted here.
- uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72 # v1.7.2
name: Create tag
if: inputs.VERSION == 'testing'
with:
tag: "${{ steps.sanitize.outputs.version }}"
message: "${{ steps.sanitize.outputs.version }}"
force_push_tag: true
# Extract and preserve changelog formatting
- name: Extract changelog
if: inputs.VERSION != 'testing'
run: |
# Extract the changelog content
VERSION="${{ inputs.VERSION }}"
# Check if this is a stable release (no -rc/-beta/-alpha or ~rc/~beta/~alpha suffix)
if [[ ! "$VERSION" =~ [-~](rc|beta|alpha) ]]; then
# For stable releases, extract the stable section and all related RC/beta sections
# Extract major.minor.patch version (e.g., 1.6.5 from 1.6.5)
BASE_VERSION=$(echo "$VERSION" | grep -oP '^\d+\.\d+\.\d+')
# Find the line number of the current version header
start_line=$(grep -n "^## v${BASE_VERSION}" CHANGELOG.md | head -1 | cut -d: -f1)
[ -n "$start_line" ] || { echo "::error::CHANGELOG.md has no '## v${BASE_VERSION}' section"; exit 1; }
# Find the line number of the next different version (not rc/beta/alpha of current version)
end_line=$(awk -v start="$start_line" -v base="$BASE_VERSION" '
NR > start && /^## v/ {
# Extract version from header
ver = $0
sub(/^## v/, "", ver)
sub(/ .*$/, "", ver)
sub(/[-~].*$/, "", ver)
if (ver != base) {
print NR
exit
}
}
' CHANGELOG.md)
# If no next version found, extract to end of file
if [ -z "$end_line" ]; then
content=$(awk -v start="$start_line" 'NR >= start' CHANGELOG.md | grep -v '# Changelog' | grep -v '##' | sed '/^$/d')
else
content=$(awk -v start="$start_line" -v end="$end_line" 'NR >= start && NR < end' CHANGELOG.md | grep -v '# Changelog' | grep -v '##' | sed '/^$/d')
fi
else
# For RC/beta/alpha releases, extract only the specific section
# Find the line number of the specific version header
start_line=$(grep -n "^## v${VERSION}" CHANGELOG.md | head -1 | cut -d: -f1)
[ -n "$start_line" ] || { echo "::error::CHANGELOG.md has no '## v${VERSION}' section"; exit 1; }
# Find the line number of the next version header
end_line=$(awk -v start="$start_line" 'NR > start && /^## v/ {print NR; exit}' CHANGELOG.md)
# If no next version found, extract to end of file
if [ -z "$end_line" ]; then
content=$(awk -v start="$start_line" 'NR >= start' CHANGELOG.md | grep -v '# Changelog' | grep -v '##' | sed '/^$/d')
else
content=$(awk -v start="$start_line" -v end="$end_line" 'NR >= start && NR < end' CHANGELOG.md | grep -v '# Changelog' | grep -v '##' | sed '/^$/d')
fi
fi
[ -n "$content" ] || { echo "::error::changelog section for v${VERSION} is empty"; exit 1; }
delimiter="CHANGELOG_$(date +%s%N)"
{
echo "DECODED_CHANGELOG<<$delimiter"
echo "$content"
echo "$delimiter"
} >> "$GITHUB_ENV"
- name: Claim draft and upload candidate assets
id: claim
if: inputs.VERSION != 'testing'
run: |
python3 .github/scripts/release_claim.py
echo "manifest_sha256=$MANIFEST_SHA256" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
MANIFEST_SHA256: ${{ inputs.MANIFEST_SHA256 }}
PRERELEASE: ${{ inputs.PRERELEASE && 'true' || 'false' }}
RELEASE_BODY: |
Documentation : https://docs.bunkerweb.io/${{ inputs.VERSION }}/
Docker tags :
- All-in-one : `bunkerity/bunkerweb-all-in-one:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-all-in-one:${{ steps.sanitize.outputs.version }}`
- BunkerWeb : `bunkerity/bunkerweb:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb:${{ steps.sanitize.outputs.version }}`
- Scheduler : `bunkerity/bunkerweb-scheduler:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-scheduler:${{ steps.sanitize.outputs.version }}`
- Autoconf : `bunkerity/bunkerweb-autoconf:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-autoconf:${{ steps.sanitize.outputs.version }}`
- UI : `bunkerity/bunkerweb-ui:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-ui:${{ steps.sanitize.outputs.version }}`
- API : `bunkerity/bunkerweb-api:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-api:${{ steps.sanitize.outputs.version }}`
GitLab mirror : `registry.gitlab.com/bunkerity/bunkerweb/<image>:${{ steps.sanitize.outputs.version }}` (same digests)
Linux packages : https://packagecloud.io/app/bunkerity/bunkerweb/search?q=${{ inputs.VERSION }}&filter=all&dist=
Changelog :
${{ env.DECODED_CHANGELOG }}
# Create release
- name: Create release
if: inputs.VERSION == 'testing'
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
with:
body: |
**The testing version of BunkerWeb should not be used in production, please use the latest stable version instead.**
Documentation : https://docs.bunkerweb.io/${{ inputs.VERSION }}/
Docker tags :
- BunkerWeb : `bunkerity/bunkerweb:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb:${{ steps.sanitize.outputs.version }}`
- Scheduler : `bunkerity/bunkerweb-scheduler:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-scheduler:${{ steps.sanitize.outputs.version }}`
- Autoconf : `bunkerity/bunkerweb-autoconf:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-autoconf:${{ steps.sanitize.outputs.version }}`
- UI : `bunkerity/bunkerweb-ui:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-ui:${{ steps.sanitize.outputs.version }}`
- API : `bunkerity/bunkerweb-api:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-api:${{ steps.sanitize.outputs.version }}`
- All-in-one : `bunkerity/bunkerweb-all-in-one:${{ steps.sanitize.outputs.version }}` or `ghcr.io/bunkerity/bunkerweb-all-in-one:${{ steps.sanitize.outputs.version }}`
Linux packages : https://packagecloud.io/app/bunkerity/bunkerweb/search?q=${{ inputs.VERSION }}&filter=all&dist=
Please note that when using Linux Debian or Ubuntu integration, you will need to add the `force-bad-version` directive to your `/etc/dpkg/dpkg.cfg` file before installing the testing version of BunkerWeb.
draft: false
prerelease: ${{ inputs.PRERELEASE }}
name: Testing
tag_name: ${{ steps.sanitize.outputs.version }}
files: |
misc/install-bunkerweb.sh
misc/install-bunkerweb.sh.sha256