Skip to content

Commit d575d12

Browse files
authored
Update GitHub Actions release automation (#550)
- Replace custom winget action with vedantmgoyal9/winget-releaser - Bump softprops/action-gh-release from v1 to v2 - Add update-binaries job to auto-generate hash configs and open PRs against ungoogled-software/ungoogled-chromium-binaries
1 parent da4a45c commit d575d12

5 files changed

Lines changed: 99 additions & 152 deletions

File tree

.github/actions/winget/action.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/actions/winget/index.js

Lines changed: 0 additions & 115 deletions
This file was deleted.

.github/actions/winget/package.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/scripts/gen.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import datetime
2+
import hashlib
3+
import os
4+
5+
import requests
6+
7+
tag = os.environ['GITHUB_REF_NAME']
8+
config = [
9+
('32bit', 'x86'),
10+
('64bit', 'x64'),
11+
('arm64', 'arm64'),
12+
]
13+
endings = [
14+
('installer', 'exe'),
15+
('windows', 'zip'),
16+
]
17+
hashes = (('md5', hashlib.md5), ('sha1', hashlib.sha1), ('sha256', hashlib.sha256))
18+
for c_path, c_name in config:
19+
lines = []
20+
lines.append('[_metadata]')
21+
lines.append(f'publication_time = {datetime.datetime.now().isoformat()}')
22+
lines.append('github_author = github-actions')
23+
lines.append('# Add a `note` field here for additional information. Markdown is supported')
24+
25+
for ending in endings:
26+
lines.append('')
27+
filename_tag = tag[:-1] + '1'
28+
name = f'ungoogled-chromium_{filename_tag}_{ending[0]}_{c_name}.{ending[1]}'
29+
lines.append(f'[{name}]')
30+
lines.append(f'url = https://github.com/ungoogled-software/ungoogled-chromium-windows/releases/download/{tag}/{name}')
31+
32+
with requests.get(f'https://github.com/ungoogled-software/ungoogled-chromium-windows/releases/download/{tag}/{name}', stream=True) as r:
33+
r.raise_for_status()
34+
hash_instances = [(h_name, h()) for h_name, h in hashes]
35+
for chunk in r.iter_content(65536):
36+
for _, h in hash_instances:
37+
h.update(chunk)
38+
for h_name, h in hash_instances:
39+
h = h.hexdigest()
40+
lines.append(f'{h_name} = {h}')
41+
with open(f'config/platforms/windows/{c_path}/{tag[:-2]}.ini', 'w') as f:
42+
f.write('\n'.join(lines))

.github/workflows/main.yml

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ jobs:
12541254
name: chromium-arm
12551255
- name: Publish release
12561256
id: publish
1257-
uses: softprops/action-gh-release@v1
1257+
uses: softprops/action-gh-release@v2
12581258
with:
12591259
fail_on_unmatched_files: true
12601260
files: |
@@ -1263,17 +1263,63 @@ jobs:
12631263
assets: ${{ steps.publish.outputs.assets }}
12641264
publish-winget:
12651265
needs: publish-release
1266-
runs-on: windows-2022
1266+
runs-on: ubuntu-slim
12671267
steps:
1268-
- name: Checkout
1268+
- name: Get version
1269+
id: version
1270+
run: echo "version=$(echo '${{ github.ref_name }}' | cut -d'-' -f1)" >> $GITHUB_OUTPUT
1271+
- uses: vedantmgoyal9/winget-releaser@main
1272+
with:
1273+
identifier: eloston.ungoogled-chromium
1274+
token: ${{ secrets.PAT }}
1275+
installers-regex: .(exe|zip)$
1276+
version: ${{ steps.version.outputs.version }}
1277+
fork-user: Nifury
1278+
update-binaries:
1279+
needs: publish-release
1280+
runs-on: ubuntu-latest
1281+
steps:
1282+
- name: Checkout ungoogled-chromium-windows
1283+
uses: actions/checkout@v3
1284+
with:
1285+
path: ungoogled-chromium-windows
1286+
- name: Checkout ungoogled-chromium-binaries
12691287
uses: actions/checkout@v3
1270-
- name: Setup Stage
1271-
run: npm install
1272-
working-directory: ./.github/actions/winget
1273-
- name: Run Stage
1274-
id: stage
1275-
uses: ./.github/actions/winget
12761288
with:
1289+
repository: Nifury/ungoogled-chromium-binaries
12771290
token: ${{ secrets.PAT }}
1278-
version: ${{ github.ref_name }}
1279-
assets: ${{ needs.publish-release.outputs.assets }}
1291+
path: ungoogled-chromium-binaries
1292+
- name: Rebase onto upstream master
1293+
working-directory: ungoogled-chromium-binaries
1294+
run: |
1295+
git remote add upstream https://github.com/ungoogled-software/ungoogled-chromium-binaries.git
1296+
git fetch upstream
1297+
git rebase upstream/master
1298+
- name: Set up Python 3.12
1299+
uses: actions/setup-python@v5
1300+
with:
1301+
python-version: '3.12'
1302+
- name: Install dependencies
1303+
run: pip install requests
1304+
- name: Run gen.py
1305+
working-directory: ungoogled-chromium-binaries
1306+
run: python ../ungoogled-chromium-windows/.github/scripts/gen.py
1307+
- name: Commit and push
1308+
working-directory: ungoogled-chromium-binaries
1309+
run: |
1310+
git config user.name "github-actions"
1311+
git config user.email "github-actions@github.com"
1312+
git add config/platforms/windows/
1313+
git commit -m "Update Windows binaries for ${{ github.ref_name }}"
1314+
git push --force-with-lease
1315+
- name: Create pull request
1316+
working-directory: ungoogled-chromium-binaries
1317+
run: |
1318+
gh pr create \
1319+
--repo ungoogled-software/ungoogled-chromium-binaries \
1320+
--head Nifury:master \
1321+
--base master \
1322+
--title "Update Windows binaries for ${{ github.ref_name }}" \
1323+
--body "Automated update of Windows binary hashes for release ${{ github.ref_name }}."
1324+
env:
1325+
GH_TOKEN: ${{ secrets.PAT }}

0 commit comments

Comments
 (0)