Skip to content

Commit 23ca686

Browse files
committed
CI: make build-ripunzip.yml auto-create update PR
1 parent 3de598e commit 23ca686

1 file changed

Lines changed: 72 additions & 9 deletions

File tree

.github/workflows/build-ripunzip.yml

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,36 @@ on:
44
workflow_dispatch:
55
inputs:
66
ripunzip-version:
7-
description: "what reference to checktout from google/runzip"
7+
description: What reference to checktout from google/runzip. Latest by default
88
required: false
99
openssl-version:
10-
description: "what reference to checkout from openssl/openssl for Linux"
10+
description: What reference to checkout from openssl/openssl for Linux. Latest by default
1111
required: false
12+
open-pr:
13+
description: Open a pull request updating the ripunzip versions committed to lfs
14+
required: false
15+
default: true # will be false on PRs
1216
pull_request:
1317
paths:
1418
- .github/workflows/build-ripunzip.yml
15-
env:
16-
RIPUNZIP_DEFAULT: v2.0.3
17-
OPENSSL_DEFAULT: openssl-3.6.0
1819

1920
jobs:
21+
versions:
22+
runs-on: ubuntu-slim
23+
outputs:
24+
ripunzip-version: ${{ inputs.ripunzip-version || steps.fetch-ripunzip-version.outputs.version }}
25+
openssl-version: ${{ inputs.openssl-version || steps.fetch-openssl-version.outputs.version }}
26+
steps:
27+
- name: Fetch latest ripunzip version
28+
id: fetch-ripunzip-version
29+
if: "!inputs.ripunzip-version"
30+
run: echo "version=$(gh release view --repo google/ripunzip) --json tagName --jq .tagName)" | tee -a $GITHUB_OUTPUT
31+
- name: Fetch latest openssl version
32+
id: fetch-openssl-version
33+
if: "!inputs.openssl-version"
34+
run: echo "version=$(gh release view --repo openssl/openssl) --json tagName --jq .tagName)" | tee -a $GITHUB_OUTPUT
2035
build:
36+
needs: versions
2137
strategy:
2238
fail-fast: false
2339
matrix:
@@ -27,7 +43,7 @@ jobs:
2743
- uses: actions/checkout@v5
2844
with:
2945
repository: google/ripunzip
30-
ref: ${{ inputs.ripunzip-version || env.RIPUNZIP_DEFAULT }}
46+
ref: ${{ needs.versions.outputs.ripunzip-version }}
3147
# we need to avoid ripunzip dynamically linking into libssl
3248
# see https://github.com/sfackler/rust-openssl/issues/183
3349
- if: runner.os == 'Linux'
@@ -36,7 +52,7 @@ jobs:
3652
with:
3753
repository: openssl/openssl
3854
path: openssl
39-
ref: ${{ inputs.openssl-version || env.OPENSSL_DEFAULT }}
55+
ref: ${{ needs.versions.outputs.openssl-version }}
4056
- if: runner.os == 'Linux'
4157
name: build and install openssl with fPIC
4258
shell: bash
@@ -68,11 +84,58 @@ jobs:
6884
lipo -create -output ripunzip-macos \
6985
-arch x86_64 target/x86_64-apple-darwin/release/ripunzip \
7086
-arch arm64 target/aarch64-apple-darwin/release/ripunzip
71-
- uses: actions/upload-artifact@v4
87+
- name: Archive (POSIX)
88+
if: runner.os != 'Windows'
89+
shell: bash
90+
run: |
91+
zip -j ripunzip-${{ runner.os }}.zip ripunzip-*
92+
- name: Archive (Windows)
93+
if: runner.os == 'Windows'
94+
shell: powershell
95+
run: |
96+
Compress-Archive -Path ripunzip-* -DestinationPath ripunzip-${{ runner.os }}.zip -Force
97+
- name: Upload built binary
98+
uses: actions/upload-artifact@v4
7299
with:
73100
name: ripunzip-${{ runner.os }}
74-
path: ripunzip-*
101+
path: ripunzip-${{ runner.os }}.zip
102+
retention-days: 5
103+
compression: 0
75104
- name: Check built binary
76105
shell: bash
77106
run: |
107+
rm -f ripunzip-*.zip
78108
./ripunzip-* --version
109+
publish:
110+
needs: [versions, build]
111+
if: inputs.open-pr == 'true'
112+
runs-on: ubuntu-slim
113+
steps:
114+
- uses: actions/checkout@v5
115+
with:
116+
sparse-checkout: |
117+
.github
118+
misc/ripunzip
119+
- name: Download built binaries
120+
uses: actions/download-artifact@v4
121+
with:
122+
merge: true
123+
path: misc/ripunzip
124+
- name: Open PR
125+
shell: bash
126+
run: |
127+
git config --global user.name "github-actions[bot]"
128+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
129+
git switch -c update-ripunzip
130+
git add misc/ripunzip
131+
git commit -m "Update ripunzip binaries to version $VERSION"
132+
git push --set-upstream origin update-ripunzip --force
133+
gh pr create \
134+
--title "Update ripunzip binaries to version $VERSION" \
135+
--body "Automated update of ripunzip binaries." \
136+
--assignee "$ACTOR"
137+
gh pr merge --auto
138+
env:
139+
ACTOR: "@${{ github.actor }}"
140+
VERSION: ${{ needs.versions.outputs.ripunzip-version }}
141+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)