Skip to content

Merge pull request #191 from airled/main #144

Merge pull request #191 from airled/main

Merge pull request #191 from airled/main #144

Workflow file for this run

name: Release on Push to Main
on:
push:
branches:
- main
workflow_dispatch: # Allow the action to be triggered manually
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Install dependencies
run: go mod tidy
- name: Get the current tag
id: get_tag
run: |
git fetch --tags
TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Current tag: $TAG"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Bump version and create tag
id: bump_version
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Get the current tag
TAG=${{ steps.get_tag.outputs.tag }}
# Extract the version number components
IFS='.' read -r -a VERSION_PARTS <<< "${TAG#v}"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}
# Increment the patch version number
NEW_TAG="v$MAJOR.$MINOR.$((PATCH + 1))"
# Create a new tag
git tag $NEW_TAG
git push origin $NEW_TAG
echo "New tag: $NEW_TAG"
echo "new_tag=$NEW_TAG" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.bump_version.outputs.new_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}