Skip to content

Commit

Permalink
feat: add version workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldo W. committed Jan 28, 2024
1 parent b805c5b commit 5d30b15
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Create version tag

on:
push:
branches:
- main
env:
TAG_VERSION: v0.0.0
PREVIOUS_TAG: 0.0.0
LATEST_TAG: 0.0.0
SHELL_SCRIPT_VERSION: 0.0.0
jobs:
create_tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check the latest version
run: |
all_tags=$(git tag | sort -rV)
read -ra all_tags_vector <<< "$all_tags"
latest_tag_version="${all_tags_vector[0]#v}"
shell_script_version=$(grep -i -E '^# version\s*=\s*"[0-9]+\.[0-9]+\.[0-9]+"' archcrystal.sh | \
grep -o -E '[0-9]+\.[0-9]+\.[0-9]+')
echo "SHELL_SCRIPT_VERSION=${shell_script_version}" >> $GITHUB_ENV
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [ $(shell_script_version#v) -ge $(latest_tag_version) ]; then
echo "NEW_TAG_FLAG='1'" >> $GITHUB_ENV
echo "::set-output name=tag-created::1"
fi
- uses: butlerlogic/action-autotag@1.1.2
if: ${{ env.NEW_TAG_FLAG != '0' }}
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
strategy: regex
root: archcrystal.sh
regex_pattern: $SHELL_SCRIPT_VERSION
tag_prefix: v
2 changes: 2 additions & 0 deletions archcrystal.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# Script Name: archcrystal.sh
# Version: 1.0.0

set -a
BASE_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
Expand Down

0 comments on commit 5d30b15

Please sign in to comment.