From 69ed6616a0f85ee4a57b0522424c7b0d3b5036ef Mon Sep 17 00:00:00 2001 From: Keegan Leary Date: Thu, 12 Dec 2024 14:09:10 -0800 Subject: [PATCH] added version control script --- .github/workflows/auto-tag.yml | 46 ++++++++++++++++++++++++++++++++++ .version | 1 + 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/auto-tag.yml create mode 100644 .version diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml new file mode 100644 index 0000000..b498f44 --- /dev/null +++ b/.github/workflows/auto-tag.yml @@ -0,0 +1,46 @@ +# This GitHub Action workflow automates the process of incrementing a version number stored in a .version file +# every time a push is made to the main branch. It performs the following steps: +# 1. Checks out the repository code. +# 2. Reads the current version from the .version file and increments it. +# 3. Commits the updated .version file back to the main branch. +# 4. Creates a new git tag with the incremented version number. +# 5. Pushes the new tag to the remote repository. + +# To deploy a new version of code all you have to do is push to the main branch. +# The version number will be incremented and a new tag will be created and pushed to the remote repository. +# Then, in GitHub Releases, you can create a new release based on the tag that was just created. +# Finally, update the CDN script (jsDelivr) to point to the new version number. + +name: Auto Increment Version + +on: + push: + branches: + - main + +jobs: + create-tag: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Read the current version and increment + run: | + echo "OLD_VERSION=$(cat .version)" >> $GITHUB_ENV + NEW_VERSION=$(( $(cat .version) + 1 )) + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + echo $NEW_VERSION > .version + + - name: Commit and Push Changes + run: | + git config --global user.name 'GitHub Action' + git config --global user.email 'action@github.com' + git add .version + git commit -m "Increment version to ${{ env.NEW_VERSION }}" + git push origin main + + - name: Tag New Version and Push Tag + run: | + git tag ${{ env.NEW_VERSION }} + git push origin tag ${{ env.NEW_VERSION }} diff --git a/.version b/.version new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/.version @@ -0,0 +1 @@ +2 \ No newline at end of file