Repository navigation
release: publish v0.4.0 #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,128 @@ | ||||||||||||
| name: Publish GitHub Release | ||||||||||||
|
|
||||||||||||
| on: | ||||||||||||
| pull_request: | ||||||||||||
| paths: | ||||||||||||
| - package.json | ||||||||||||
| - CHANGELOG.md | ||||||||||||
| - .github/workflows/publish-release.yml | ||||||||||||
| push: | ||||||||||||
| branches: [main] | ||||||||||||
| paths: | ||||||||||||
| - package.json | ||||||||||||
| - CHANGELOG.md | ||||||||||||
| - .github/workflows/publish-release.yml | ||||||||||||
| workflow_dispatch: | ||||||||||||
|
|
||||||||||||
| permissions: | ||||||||||||
| contents: write | ||||||||||||
|
|
||||||||||||
| concurrency: | ||||||||||||
| group: publish-release | ||||||||||||
| cancel-in-progress: false | ||||||||||||
|
|
||||||||||||
| jobs: | ||||||||||||
| publish: | ||||||||||||
| name: publish-release | ||||||||||||
| runs-on: ubuntu-24.04 | ||||||||||||
| timeout-minutes: 5 | ||||||||||||
| steps: | ||||||||||||
| - name: Checkout full history | ||||||||||||
| uses: actions/checkout@v5 | ||||||||||||
| with: | ||||||||||||
| fetch-depth: 0 | ||||||||||||
| fetch-tags: true | ||||||||||||
|
|
||||||||||||
| - name: Resolve release metadata | ||||||||||||
| id: metadata | ||||||||||||
| shell: bash | ||||||||||||
| run: | | ||||||||||||
| set -euo pipefail | ||||||||||||
|
|
||||||||||||
| VERSION="$(node -p "require('./package.json').version")" | ||||||||||||
| TAG="v${VERSION}" | ||||||||||||
|
|
||||||||||||
| if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||||||||||||
| echo "::error::package.json version '${VERSION}' is not a stable semver release" | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| if ! grep -Fq "## [${VERSION}] - " CHANGELOG.md; then | ||||||||||||
| echo "CHANGELOG has no finalized section for ${TAG}; publication is not ready yet." | ||||||||||||
| echo "ready=false" >> "$GITHUB_OUTPUT" | ||||||||||||
| exit 0 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| RELEASE_SHA="$(git log --merges --fixed-strings --grep="release: ${TAG}" --format='%H' -n 1)" | ||||||||||||
|
|
||||||||||||
| if [[ -z "$RELEASE_SHA" ]]; then | ||||||||||||
| echo "::error::Could not find the merge commit for release: ${TAG}" | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||||||||||||
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | ||||||||||||
| echo "release_sha=${RELEASE_SHA}" >> "$GITHUB_OUTPUT" | ||||||||||||
| echo "ready=true" >> "$GITHUB_OUTPUT" | ||||||||||||
|
|
||||||||||||
| - name: Extract CHANGELOG release notes | ||||||||||||
| if: steps.metadata.outputs.ready == 'true' | ||||||||||||
| env: | ||||||||||||
| VERSION: ${{ steps.metadata.outputs.version }} | ||||||||||||
| shell: bash | ||||||||||||
| run: | | ||||||||||||
| python3 - <<'PY' | ||||||||||||
| import os | ||||||||||||
| import re | ||||||||||||
| from pathlib import Path | ||||||||||||
|
|
||||||||||||
| version = os.environ["VERSION"] | ||||||||||||
| text = Path("CHANGELOG.md").read_text(encoding="utf-8") | ||||||||||||
| pattern = re.compile( | ||||||||||||
| rf"^## \[{re.escape(version)}\] - \d{{4}}-\d{{2}}-\d{{2}}\n(.*?)(?=^## \[)", | ||||||||||||
| re.MULTILINE | re.DOTALL, | ||||||||||||
| ) | ||||||||||||
| match = pattern.search(text) | ||||||||||||
| if not match: | ||||||||||||
| raise SystemExit(f"Could not extract CHANGELOG section for v{version}") | ||||||||||||
|
|
||||||||||||
| notes = match.group(1).strip() + "\n" | ||||||||||||
| Path("/tmp/release-notes.md").write_text(notes, encoding="utf-8") | ||||||||||||
| PY | ||||||||||||
|
|
||||||||||||
| - name: Publish tag and GitHub Release | ||||||||||||
| if: steps.metadata.outputs.ready == 'true' && github.event_name != 'pull_request' | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '1,180p' .github/workflows/publish-release.yml
sed -n '130,180p' docs/release.mdRepository: ido-bata/ido-bata.github.io Length of output: 5895 🤖 get_repo_knowledge executed:
Length of output: 19288 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- release documentation candidates ---'
fd -i -t f 'release' . | head -80
printf '%s\n' '--- repository control files ---'
git ls-files '.github' | sort
printf '%s\n' '--- release guide context ---'
sed -n '1,170p' docs/release.md
printf '%s\n' '--- workflow and branch-control references ---'
rg -n -S 'workflow_dispatch|publish-release|release|CODEOWNERS|branch protection|main' .github docs README.md 2>/dev/null | head -240Repository: ido-bata/ido-bata.github.io Length of output: 28638 Prevent manual runs from publishing non-main revisions.
Restrict publication to pushes on Proposed event guard- if: steps.metadata.outputs.ready == 'true' && github.event_name != 'pull_request'
+ if: >-
+ steps.metadata.outputs.ready == 'true' &&
+ github.event_name == 'push' &&
+ github.ref == 'refs/heads/main'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
| env: | ||||||||||||
| GH_TOKEN: ${{ github.token }} | ||||||||||||
| TAG: ${{ steps.metadata.outputs.tag }} | ||||||||||||
| RELEASE_SHA: ${{ steps.metadata.outputs.release_sha }} | ||||||||||||
| shell: bash | ||||||||||||
| run: | | ||||||||||||
| set -euo pipefail | ||||||||||||
|
|
||||||||||||
| if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then | ||||||||||||
| echo "GitHub Release $TAG already exists; nothing to do." | ||||||||||||
| exit 0 | ||||||||||||
| fi | ||||||||||||
|
Comment on lines
+103
to
+106
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '90,140p' .github/workflows/publish-release.yml
sed -n '145,175p' docs/release.mdRepository: ido-bata/ido-bata.github.io Length of output: 2685 🏁 Script executed: cat -n .github/workflows/publish-release.yml | sed -n '1,125p'
printf '\n--- release documentation ---\n'
cat -n docs/release.md | sed -n '1,175p'Repository: ido-bata/ido-bata.github.io Length of output: 13862 Validate the tag target before accepting an existing release. When Fetch and validate the tag first. Return successfully only after its commit equals 🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| git fetch --tags --force | ||||||||||||
|
|
||||||||||||
| if git rev-parse --verify --quiet "refs/tags/$TAG" >/dev/null; then | ||||||||||||
| TAG_SHA="$(git rev-list -n 1 "$TAG")" | ||||||||||||
| if [[ "$TAG_SHA" != "$RELEASE_SHA" ]]; then | ||||||||||||
| echo "::error::Existing tag $TAG points to $TAG_SHA, expected $RELEASE_SHA" | ||||||||||||
| exit 1 | ||||||||||||
| fi | ||||||||||||
|
|
||||||||||||
| gh release create "$TAG" \ | ||||||||||||
| --repo "$GITHUB_REPOSITORY" \ | ||||||||||||
| --verify-tag \ | ||||||||||||
| --title "$TAG" \ | ||||||||||||
| --notes-file /tmp/release-notes.md | ||||||||||||
| else | ||||||||||||
| gh release create "$TAG" \ | ||||||||||||
| --repo "$GITHUB_REPOSITORY" \ | ||||||||||||
| --target "$RELEASE_SHA" \ | ||||||||||||
| --title "$TAG" \ | ||||||||||||
| --notes-file /tmp/release-notes.md | ||||||||||||
| fi | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '36,95p' .github/workflows/publish-release.ymlRepository: ido-bata/ido-bata.github.io
Length of output: 2323
Run the merge-commit lookup only for publication events.
For a valid pull request, the version and finalized
CHANGELOG.mdchecks complete beforegit logruns. If the lookup finds no matching merge commit, the step exits before it writesready=true, so release-note extraction is skipped and pull request validation does not complete.Keep merge-SHA resolution for non-
pull_requestpublication events:Proposed fix
🤖 Prompt for AI Agents