-
Notifications
You must be signed in to change notification settings - Fork 0
ci: auto-release on merge to main #4
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
ab61aa9
82ca7fc
51a8394
c4b0a2c
f482c20
0da276b
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,71 @@ | ||
| name: Auto Release | ||
|
|
||
| # When a version bump lands on main, read the top CHANGELOG version and, if it | ||
| # has no matching tag yet, create the tag `vX.Y.Z` and call release.yml to build | ||
| # + publish it. No PAT needed — release.yml is invoked via workflow_call because | ||
| # the default token cannot let a tag push trigger another workflow. | ||
|
|
||
| "on": | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - CHANGELOG.md # only a version bump can start a release | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| concurrency: | ||
| group: auto-release | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| detect: | ||
| name: Detect new version | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| release: ${{ steps.ver.outputs.release }} | ||
| version: ${{ steps.ver.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # need all tags | ||
|
|
||
| - name: Read top CHANGELOG version | ||
| id: ver | ||
| run: | | ||
| # First "## [x.y.z]" heading — skips "## [Unreleased]". | ||
| VERSION="$(grep -m1 -oE '^## \[[0-9]+\.[0-9]+\.[0-9]+\]' CHANGELOG.md | tr -d '## []')" | ||
| if [ -z "$VERSION" ]; then | ||
| echo "No versioned CHANGELOG entry found — nothing to release." | ||
| echo "release=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| if git rev-parse "v$VERSION" >/dev/null 2>&1; then | ||
| echo "Tag v$VERSION already exists — skipping." | ||
| echo "release=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "New version detected: v$VERSION" | ||
| echo "release=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
Comment on lines
+45
to
+51
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. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== auto-release workflow ==\n'
ast-grep outline .github/workflows/auto-release.yml --view expanded || true
printf '\n== release workflow references ==\n'
rg -n "release\.yml|workflow_call|workflow_dispatch|release=false|release=true|git rev-parse|v\\$VERSION" .github/workflows -n
printf '\n== file snippets ==\n'
nl -ba .github/workflows/auto-release.yml | sed -n '1,160p'
printf '\n---- release workflow ----\n'
nl -ba .github/workflows/release.yml | sed -n '1,220p'Repository: AlfaCode-Team/http Length of output: 309 🏁 Script executed: #!/bin/bash
set -euo pipefail
nl -ba .github/workflows/auto-release.yml | sed -n '1,120p'
echo '----'
nl -ba .github/workflows/release.yml | sed -n '1,220p'Repository: AlfaCode-Team/http Length of output: 196 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '== auto-release ==\n'
sed -n '1,220p' .github/workflows/auto-release.yml
printf '\n== release ==\n'
sed -n '1,260p' .github/workflows/release.yml
printf '\n== references ==\n'
rg -n 'release\.yml|workflow_call|workflow_dispatch|release=false|release=true|git rev-parse|v\$VERSION|VERSION' .github/workflowsRepository: AlfaCode-Team/http Length of output: 5960 🏁 Script executed: #!/bin/bash
set -euo pipefail
for f in .github/workflows/auto-release.yml .github/workflows/release.yml; do
echo "===== $f ====="
cat -n "$f" | sed -n '1,220p'
doneRepository: AlfaCode-Team/http Length of output: 5382 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '== auto-release =='
sed -n '1,220p' .github/workflows/auto-release.yml
echo
echo '== release =='
sed -n '1,260p' .github/workflows/release.yml
echo
echo '== matches =='
rg -n 'release\.yml|workflow_call|workflow_dispatch|release=false|release=true|git rev-parse|v\$VERSION|VERSION' .github/workflows/auto-release.yml .github/workflows/release.ymlRepository: AlfaCode-Team/http Length of output: 5957 Always call 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Create and push tag | ||
| if: steps.ver.outputs.release == 'true' | ||
| env: | ||
| VERSION: ${{ steps.ver.outputs.version }} | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git tag -a "v$VERSION" -m "Release v$VERSION" | ||
| git push origin "v$VERSION" | ||
|
|
||
| release: | ||
| name: Build & publish | ||
| needs: detect | ||
| if: needs.detect.outputs.release == 'true' | ||
| uses: ./.github/workflows/release.yml | ||
| permissions: | ||
| contents: write | ||
| with: | ||
| version: ${{ needs.detect.outputs.version }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,21 @@ | ||
| name: Release | ||
|
|
||
| # Publishes a GitHub Release. Two entry points: | ||
| # • a pushed tag `v*` — manual escape hatch | ||
| # • workflow_call(version) — invoked by auto-release.yml on merge to main | ||
| # (the default token cannot let a tag push trigger this workflow, so the | ||
| # auto-release path calls it directly). | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| workflow_call: | ||
| inputs: | ||
| version: | ||
| description: 'Release version without the leading v (e.g. 1.2.0)' | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
@@ -34,11 +46,24 @@ jobs: | |
| - uses: actions/checkout@v7 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Create release | ||
| - name: Resolve tag | ||
| id: tag | ||
| run: | | ||
| if [ -n "${{ inputs.version }}" ]; then | ||
| echo "tag=v${{ inputs.version }}" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
Comment on lines
+49
to
+56
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. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Map the workflow and any callers first.
git ls-files '.github/workflows/*' '.*' | sed -n '1,200p'Repository: AlfaCode-Team/http Length of output: 462 🏁 Script executed: #!/bin/bash
set -euo pipefail
git ls-files .github/workflows | sed -n '1,200p'Repository: AlfaCode-Team/http Length of output: 246 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Show the relevant workflow section with line numbers.
cat -n .github/workflows/release.yml | sed -n '1,140p'Repository: AlfaCode-Team/http Length of output: 2526 🏁 Script executed: #!/bin/bash
set -euo pipefail
# Find workflow callers and references to the release workflow.
rg -n "release\.yml|workflow_call|inputs\.version|Resolve tag" .github/workflows -SRepository: AlfaCode-Team/http Length of output: 871 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== workflow files ==="
git ls-files .github/workflows
echo "=== release.yml lines 1-180 ==="
cat -n .github/workflows/release.yml | sed -n '1,180p'Repository: AlfaCode-Team/http Length of output: 2671 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== search for reusable workflow declaration and callers ==="
rg -n "workflow_call|uses: \.\/\.github\/workflows\/release\.yml|inputs\.version|version:" .github/workflows -SRepository: AlfaCode-Team/http Length of output: 1199 🏁 Script executed: #!/bin/bash
set -euo pipefail
cat -n .github/workflows/release.yml | sed -n '1,180p'Repository: AlfaCode-Team/http Length of output: 2526 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
p = Path('.github/workflows/release.yml')
print(p.read_text())
PYRepository: AlfaCode-Team/http Length of output: 2044 Don't interpolate 🧰 Tools🪛 zizmor (1.26.1)[error] 52-52: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) [error] 53-53: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| - name: Create release (idempotent) | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| TAG: ${{ steps.tag.outputs.tag }} | ||
| run: | | ||
| gh release create "${GITHUB_REF_NAME}" \ | ||
| --title "${GITHUB_REF_NAME}" \ | ||
| if gh release view "$TAG" >/dev/null 2>&1; then | ||
| echo "Release $TAG already exists — nothing to do." | ||
| exit 0 | ||
| fi | ||
| gh release create "$TAG" \ | ||
| --title "$TAG" \ | ||
| --generate-notes \ | ||
| --verify-tag | ||
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 | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: AlfaCode-Team/http
Length of output: 247
🏁 Script executed:
Repository: AlfaCode-Team/http
Length of output: 644
🏁 Script executed:
Repository: AlfaCode-Team/http
Length of output: 1576
🏁 Script executed:
Repository: AlfaCode-Team/http
Length of output: 1130
Check the exact tag ref.
git rev-parse "v$VERSION"matches any ref namedv$VERSION, including branches, so a real release can be skipped. Usegit show-ref --verify --quiet "refs/tags/v$VERSION"instead.🤖 Prompt for AI Agents