Skip to content

Commit 257ca99

Browse files
committed
ci: implementing versioning such that the prior tag is taken and moved into the version folder
1 parent 79918ea commit 257ca99

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/versioning.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Versioning
2+
on:
3+
push:
4+
# Will not trigger on a release candidate
5+
tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]
6+
7+
jobs:
8+
versioning:
9+
name: versioning
10+
runs-on: ubuntu-latest
11+
steps:
12+
# Clone the pushed tag
13+
- name: Clone tag
14+
uses: actions/checkout@v4
15+
16+
# Get the tag for the prior version
17+
- name: Get prior version
18+
id: get_tag
19+
run: |
20+
PRIOR_VERSION=$(git tag -l --sort=-v:refname | head -n 1 | sed "s/v//g" | sed "s/\./-/g")
21+
echo "PRIOR_VERSION=$PRIOR_VERSION" >> $GITHUB_ENV
22+
echo "Prior version tag: $PRIOR_VERSION"
23+
24+
# Clone the prior tag
25+
- name: Clone prior branch
26+
uses: actions/checkout@v4
27+
with:
28+
ref: ${{ steps.get_tag.outputs.PRIOR_VERSION }}
29+
path: prior
30+
fetch-depth: 0
31+
32+
# Move latest of the prior tag to corresponding version folder
33+
- name: Move prior latest to versions
34+
shell: bash
35+
run: |
36+
mkdir "content/versions/$PRIOR_VERSION"
37+
cp -r prior/content/latest "content/versions/$PRIOR_VERSION"
38+
rm -r prior
39+
40+
# Commit everything to main
41+
- name: Commit and replace
42+
run: |
43+
git add .
44+
git commit -m "Migrated ${{ github.ref_name }} into latest"
45+
git push origin main

0 commit comments

Comments
 (0)