Skip to content

Commit e45cd90

Browse files
committed
ci: simplify publish workflow to comply with GitHub restrictions
Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent be6d790 commit e45cd90

4 files changed

Lines changed: 13 additions & 51 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
- [ ] `socket_basics/version.py` updated to new version
2727
- [ ] `socket_basics/__init__.py` updated to the same version
2828
- [ ] `action.yml` `image:` ref updated to `docker://ghcr.io/socketdev/socket-basics:<new-version>`
29-
- [ ] `CHANGELOG.md` `[Unreleased]` section reviewed
29+
- [ ] `CHANGELOG.md` updated with human-authored release notes for this version

.github/workflows/_docker-pipeline.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ name: _docker-pipeline (reusable)
77
#
88
# Two modes:
99
# push: false → build + smoke test + integration test (main image only)
10-
# push: true → above + push to GHCR/Docker Hub + update floating v-tag
10+
# push: true → above + push exact version tags to GHCR/Docker Hub
1111
#
1212
# Permissions required from the calling workflow:
1313
# push: false → contents: read
14-
# push: true → contents: write, packages: write
14+
# push: true → contents: read, packages: write
1515

1616
on:
1717
workflow_call:
@@ -41,7 +41,7 @@ on:
4141
tag_push:
4242
description: >
4343
True when the caller was triggered by a tag push (e.g. v2.0.0).
44-
Controls the floating major-version tag update and the 'latest' Docker tag.
44+
Controls semver metadata-action tagging for exact release tags.
4545
Passed explicitly rather than relying on github.ref_type inside the callee,
4646
since context propagation in reusable workflows can be ambiguous.
4747
type: boolean

.github/workflows/publish-docker.yml

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -80,64 +80,26 @@ jobs:
8080
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
8181
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
8282

83-
# ── Job 3: Create GitHub release + update CHANGELOG ────────────────────────
83+
# ── Job 3: Create GitHub release ───────────────────────────────────────────
8484
# Runs once after the image is successfully pushed (not for workflow_dispatch
8585
# re-publishes — those don't create new releases).
86-
# Generates categorised release notes from merged PR labels (.github/release.yml),
87-
# creates the GitHub Release, then commits the CHANGELOG update back to main.
86+
# Generates categorised release notes from merged PR labels (.github/release.yml).
87+
# CHANGELOG updates are intentionally human-authored in the release PR so this
88+
# workflow never needs to push commits to the protected default branch.
8889
create-release:
8990
needs: [resolve-version, build-test-push]
9091
if: github.ref_type == 'tag'
9192
permissions:
92-
contents: write # create GitHub release + commit CHANGELOG back to main
93+
contents: write # create GitHub release
9394
runs-on: ubuntu-latest
94-
env:
95-
VERSION: ${{ needs.resolve-version.outputs.version }}
9695
steps:
97-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
98-
with:
99-
ref: main
100-
fetch-depth: 0
101-
persist-credentials: false
102-
103-
- name: 🤖 Generate socket-release-bot token
104-
id: bot
105-
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
106-
with:
107-
app-id: ${{ secrets.GH_BOT_APP_ID }}
108-
private-key: ${{ secrets.GH_BOT_APP_PEM_FILE }}
109-
owner: SocketDev
110-
repositories: socket-basics
111-
11296
- name: 📝 Create GitHub release with auto-generated notes
11397
env:
114-
GH_TOKEN: ${{ steps.bot.outputs.token }}
98+
GH_TOKEN: ${{ github.token }}
11599
REF_NAME: ${{ github.ref_name }}
116100
run: |
117101
gh release create "$REF_NAME" \
118102
--title "$REF_NAME" \
119103
--generate-notes \
120104
--verify-tag \
121105
|| echo "Release already exists (re-run scenario) — skipping creation"
122-
123-
- name: 📋 Update CHANGELOG.md
124-
env:
125-
GH_TOKEN: ${{ steps.bot.outputs.token }}
126-
REF_NAME: ${{ github.ref_name }}
127-
run: |
128-
NOTES=$(gh release view "$REF_NAME" --json body --jq .body)
129-
DATE=$(date +%Y-%m-%d)
130-
echo "$NOTES" | python scripts/update_changelog.py \
131-
--version "$VERSION" \
132-
--date "$DATE"
133-
134-
- name: 🔀 Commit CHANGELOG back to main
135-
env:
136-
BOT_TOKEN: ${{ steps.bot.outputs.token }}
137-
run: |
138-
git config user.name "socket-release-bot[bot]"
139-
git config user.email "socket-release-bot[bot]@users.noreply.github.com"
140-
git remote set-url origin "https://x-access-token:${BOT_TOKEN}@github.com/SocketDev/socket-basics.git"
141-
git add CHANGELOG.md
142-
git diff --cached --quiet || git commit -m "chore: release ${github.ref_name} — update CHANGELOG [skip ci]"
143-
git push origin HEAD:main

scripts/update_changelog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"""
33
update_changelog.py — Prepend a new release section to CHANGELOG.md.
44
5-
Called automatically by the publish-docker workflow after a GitHub Release
6-
is created. Reads the generated release notes, inserts a new version section
7-
immediately after [Unreleased], and updates the comparison links at the bottom.
5+
Legacy helper for applying generated release notes locally. The publish-docker
6+
workflow intentionally does not call this script anymore, because release
7+
changelog updates are human-authored in the release PR.
88
99
Usage:
1010
# Notes from a file:

0 commit comments

Comments
 (0)