Skip to content

Commit 8cef7c7

Browse files
committed
Create release.yml
Automate release zips and make them generate the folder name correctly This helps users download a correctly named script so they dont end up with a script with a version number in the title
1 parent ad4868d commit 8cef7c7

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# VCS / CI noise
2+
.gitattributes export-ignore
3+
.gitignore export-ignore
4+
.github/** export-ignore
5+
.gitmodules export-ignore
6+
7+
# Dev tooling/config
8+
.vscode/** export-ignore
9+
*.code-workspace export-ignore
10+
.editorconfig export-ignore
11+
.eslintrc* export-ignore
12+
.prettier* export-ignore

.github/workflows/release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Package & Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
- "*.*.*"
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout (full history)
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Derive vars
22+
id: vars
23+
shell: bash
24+
run: |
25+
echo "name=${GITHUB_REPOSITORY##*/}" >> $GITHUB_OUTPUT # e.g. jim_bridge
26+
echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT # strip leading v
27+
28+
- name: Build zip with folder prefix
29+
shell: bash
30+
run: |
31+
NAME='${{ steps.vars.outputs.name }}'
32+
VER='${{ steps.vars.outputs.version }}'
33+
git archive --format=zip --prefix="${NAME}/" -o "${NAME}-${VER}.zip" "$GITHUB_REF_NAME"
34+
ls -lh "${NAME}-${VER}.zip"
35+
36+
# --- Patch notes generation (commit titles + links) -------------------
37+
- name: Find previous tag (SemVer aware)
38+
id: prev
39+
shell: bash
40+
run: |
41+
CUR="${GITHUB_REF_NAME}"
42+
# Sort tags by version desc, drop the current, take the next newest
43+
PREV=$(git tag --sort=-v:refname | grep -v -x "$CUR" | head -n 1 || true)
44+
echo "prev=$PREV" >> $GITHUB_OUTPUT
45+
echo "Previous tag: ${PREV:-<none>}"
46+
47+
- name: Generate RELEASE_NOTES.md from commits
48+
shell: bash
49+
run: |
50+
REPO="${{ github.repository }}"
51+
CUR="${GITHUB_REF_NAME}"
52+
PREV='${{ steps.prev.outputs.prev }}'
53+
54+
if [ -n "$PREV" ]; then
55+
RANGE="$PREV..$CUR"
56+
HEADER="## Changes in $CUR"
57+
else
58+
# First release: include all commits
59+
ROOT=$(git rev-list --max-parents=0 HEAD | tail -n 1)
60+
RANGE="$ROOT..$CUR"
61+
HEADER="## Changes"
62+
fi
63+
64+
{
65+
echo "$HEADER"
66+
echo
67+
# Oldest → newest, subject only, skip merge commits
68+
# Escape '[' and ']' so markdown doesn't break on rare titles
69+
git log --reverse --no-merges --pretty=format:'- ['%h'] - %s' "$RANGE" \
70+
| perl -pe 's/([\[\]])/\\$1/g'
71+
} > RELEASE_NOTES.md
72+
73+
echo "--- RELEASE_NOTES.md ---"
74+
cat RELEASE_NOTES.md
75+
echo "------------------------"
76+
77+
- name: Create / Update GitHub Release
78+
uses: softprops/action-gh-release@v2
79+
with:
80+
tag_name: ${{ github.ref_name }}
81+
name: ${{ github.ref_name }}
82+
files: |
83+
*.zip
84+
body_path: RELEASE_NOTES.md # attach our generated notes
85+
# If you wanted GitHub's auto notes instead, set:
86+
# generate_release_notes: true
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)