From 257ca99a9cc88546d02fdbc960d8df6739eaadd8 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Tue, 8 Apr 2025 03:55:00 -0700 Subject: [PATCH 1/2] ci: implementing versioning such that the prior tag is taken and moved into the version folder --- .github/workflows/versioning.yaml | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/versioning.yaml diff --git a/.github/workflows/versioning.yaml b/.github/workflows/versioning.yaml new file mode 100644 index 000000000..d6bd0f3b6 --- /dev/null +++ b/.github/workflows/versioning.yaml @@ -0,0 +1,45 @@ +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 + + # Get the tag for the prior version + - name: Get prior version + id: get_tag + run: | + PRIOR_VERSION=$(git tag -l --sort=-v:refname | 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 \ No newline at end of file From b33d3553e926c121f65977f0b0a15211d3f22c21 Mon Sep 17 00:00:00 2001 From: Jarod Wilson Date: Tue, 8 Apr 2025 16:43:11 -0700 Subject: [PATCH 2/2] ci: add check for commit history against main and make it so prior version step will ignore release candidates --- .github/workflows/versioning.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/versioning.yaml b/.github/workflows/versioning.yaml index d6bd0f3b6..56b867fb2 100644 --- a/.github/workflows/versioning.yaml +++ b/.github/workflows/versioning.yaml @@ -13,11 +13,23 @@ jobs: - 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 | head -n 1 | sed "s/v//g" | sed "s/\./-/g") + 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"