Skip to content

Commit 9782923

Browse files
authored
Publish prek-action known versions after release (#1814)
1 parent 1376f46 commit 9782923

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: "Publish prek-action known versions"
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
plan:
7+
required: true
8+
type: string
9+
secrets:
10+
PREK_ACTION_TOKEN:
11+
required: true
12+
13+
permissions: {}
14+
15+
jobs:
16+
publish:
17+
name: Publish prek-action known versions
18+
runs-on: ubuntu-latest
19+
environment:
20+
name: release
21+
env:
22+
PLAN: ${{ inputs.plan }}
23+
steps:
24+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25+
with:
26+
repository: j178/prek-action
27+
ref: main
28+
token: ${{ secrets.PREK_ACTION_TOKEN }}
29+
persist-credentials: false
30+
31+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
32+
with:
33+
node-version: 24
34+
cache: npm
35+
36+
- name: Install dependencies
37+
run: npm ci
38+
39+
- name: Update known versions
40+
id: refresh
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.PREK_ACTION_TOKEN }}
43+
run: npm run update-known-versions
44+
45+
- name: Check whether known version files changed
46+
id: changes
47+
run: |
48+
if git diff --quiet -- version-manifest.json src/known-checksums.ts; then
49+
echo "known_versions_changed=false" >> "$GITHUB_OUTPUT"
50+
else
51+
echo "known_versions_changed=true" >> "$GITHUB_OUTPUT"
52+
fi
53+
54+
- name: Run tests
55+
if: steps.changes.outputs.known_versions_changed == 'true'
56+
run: npm test
57+
58+
- name: Rebuild dist
59+
if: steps.changes.outputs.known_versions_changed == 'true'
60+
run: npm run bundle
61+
62+
- name: Create pull request
63+
id: cpr
64+
if: steps.changes.outputs.known_versions_changed == 'true'
65+
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
66+
with:
67+
token: ${{ secrets.PREK_ACTION_TOKEN }}
68+
add-paths: |
69+
version-manifest.json
70+
src/known-checksums.ts
71+
dist/index.js
72+
dist/post/index.js
73+
branch: automation/update-known-versions
74+
base: main
75+
commit-message: ${{ steps.refresh.outputs.pr_title }}
76+
title: ${{ steps.refresh.outputs.pr_title }}
77+
body: |
78+
Automated update from the prek release workflow.
79+
80+
Added releases:
81+
${{ steps.refresh.outputs.added_versions_markdown }}
82+
83+
- name: Merge pull request
84+
if: steps.cpr.outputs.pull-request-number != ''
85+
env:
86+
GH_TOKEN: ${{ secrets.PREK_ACTION_TOKEN }}
87+
PR_NUMBER: ${{ steps.cpr.outputs.pull-request-number }}
88+
shell: bash
89+
run: |
90+
sleep 10
91+
gh pr merge --squash --repo j178/prek-action "$PR_NUMBER"

.github/workflows/release.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,15 @@ jobs:
320320
plan: ${{ needs.plan.outputs.val }}
321321
secrets: inherit
322322

323+
custom-publish-prek-action:
324+
needs:
325+
- plan
326+
- announce
327+
uses: ./.github/workflows/publish-prek-action.yml
328+
with:
329+
plan: ${{ needs.plan.outputs.val }}
330+
secrets: inherit
331+
323332
custom-publish-winget:
324333
needs:
325334
- plan

dist-workspace.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ publish-jobs = ["./publish-crates", "./publish-pypi", "./publish-npm"]
5656
post-announce-jobs = [
5757
"./publish-docs",
5858
"./publish-homebrew",
59+
"./publish-prek-action",
5960
"./publish-winget",
6061
]
6162
github-custom-job-permissions = { "publish-docs" = { contents = "read", pages = "write", id-token = "write" }, "build-docker" = { packages = "write", contents = "read", attestations = "write", id-token = "write" }, "publish-winget" = {}, "publish-crates" = { id-token = "write" }, "publish-pypi" = { id-token = "write" }, "publish-npm" = { id-token = "write" }, "publish-homebrew" = {} }

0 commit comments

Comments
 (0)