Skip to content

Commit 49b7108

Browse files
committed
Add GitHub workflow to automatically tag each commit on main (#2)
1 parent 4b8ff13 commit 49b7108

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/permaref.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Automatically creates a tag for each commit to `main` so when we rebase
2+
# changes on top of the upstream, we retain permanent references to each
3+
# previous commit so they are not orphaned and eventually deleted.
4+
name: Create permanent reference
5+
6+
on:
7+
push:
8+
branches:
9+
- "main"
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Get the permanent ref number
19+
id: get_version
20+
run: |
21+
# Enable pipefail so git command failures do not result in null versions downstream
22+
set -x
23+
24+
echo ::set-output name=LAST_PERMA_NUMBER::$(\
25+
git ls-remote --tags --refs --sort="v:refname" \
26+
https://github.com/zanieb/pubgrub.git | grep "tags/perma-" | tail -n1 | sed 's/.*\/perma-//' \
27+
)
28+
29+
- name: Configure Git
30+
run: |
31+
git config user.name "$GITHUB_ACTOR"
32+
git config user.email "[email protected]"
33+
34+
- name: Create and push the new tag
35+
run: |
36+
TAG="perma-$((LAST_PERMA_NUMBER + 1))"
37+
git tag -a "$TAG" -m "Automatically created on push to `main`"
38+
git push origin "$TAG"
39+
env:
40+
LAST_PERMA_NUMBER: ${{ steps.get_version.outputs.LAST_PERMA_NUMBER }}

0 commit comments

Comments
 (0)