Skip to content

[CI] Add Versioning Pipeline #181

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/versioning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Versioning
on:
push:
# Will not trigger on a release candidate
tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]

jobs:
versioning:
name: versioning
runs-on: ubuntu-latest
steps:
# Clone the pushed tag
- name: Clone tag
uses: actions/checkout@v4

# Check logs with main to prevent issues when pushing
- name: Ensure tag is current with main
run: |
git fetch origin
if [[ -n $(git log HEAD..origin/main --oneline) ]]; then
echo "❌ Your tag is missing commits from origin/main."
echo -e "\u2014 Pull from main before pushing tag."
exit 1
else
echo "✅ Your tag has all commits from origin/main!"
fi

# Get the tag for the prior version
- name: Get prior version
id: get_tag
run: |
PRIOR_VERSION=$(git tag -l --sort=-v:refname | grep -E "v?[0-9]+\.[0-9]+\.[0-9]+$" | head -n 1 | sed "s/v//g" | sed "s/\./-/g")
echo "PRIOR_VERSION=$PRIOR_VERSION" >> $GITHUB_ENV
echo "Prior version tag: $PRIOR_VERSION"

# Clone the prior tag
- name: Clone prior branch
uses: actions/checkout@v4
with:
ref: ${{ steps.get_tag.outputs.PRIOR_VERSION }}
path: prior
fetch-depth: 0

# Move latest of the prior tag to corresponding version folder
- name: Move prior latest to versions
shell: bash
run: |
mkdir "content/versions/$PRIOR_VERSION"
cp -r prior/content/latest "content/versions/$PRIOR_VERSION"
rm -r prior

# Commit everything to main
- name: Commit and replace
run: |
git add .
git commit -m "Migrated ${{ github.ref_name }} into latest"
git push origin main
Loading