Update Major Release #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Major Release | |
on: | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Exit if the branch is not main | |
run: | | |
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then | |
echo "Branch is not main, exiting." | |
exit 1 | |
fi | |
- name: Set Git Config | |
run: | | |
git config --global user.email "${{ secrets.USER_EMAIL }}" | |
git config --global user.name "${{ secrets.USER_NAME }}" | |
shell: bash | |
- name: Check for Existing Tags and Create | |
id: check_tags | |
run: | | |
tags=$(git ls-remote --tags origin) | |
if [ -z "$tags" ]; then | |
echo "No tags found." | |
git tag -a "v1.0" -m "Initial release" | |
git push origin "v1.0" | |
echo "::set-output name=new_tag::v1.0" | |
else | |
echo "Tags found:" | |
remote_tags=$(git ls-remote --tags origin | awk '{print $2}' | awk -F '/' '{print $3}' | sort -V | tail -n 1) | |
remote_tag="${remote_tags::-3}" | |
echo $remote_tag | |
echo "Existing tag is $remote_tag" | |
# Internal Field Separator | |
IFS='.' read -r major minor <<< "${remote_tag:1}" | |
major=$((major + 1)) | |
minor=0 | |
new_tag_version="v$major.$minor" | |
echo $new_tag_version | |
git tag -a "${new_tag_version}" -m "Release -${new_tag_version}" | |
git push origin "${new_tag_version}" | |
echo "::set-output name=new_tag::${new_tag_version}" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.check_tags.outputs.new_tag }} | |
release_name: Release ${{ steps.check_tags.outputs.new_tag }} | |
body: | | |
Get the Release Details__ |