Skip to content

Add GitHub Actions workflow for release management #1

Add GitHub Actions workflow for release management

Add GitHub Actions workflow for release management #1

Workflow file for this run

name: Build and Release using Semantic Versionning
on:
push:
branches:
- main
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-slim
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

Check failure on line 21 in .github/workflows/release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/release.yml

Invalid workflow file

You have an error in your yaml syntax on line 21
- name: Compute version
id: version
run: |
git fetch --tags
LAST_TAG=$(git tag --sort=-v:refname | head -n 1)
if [ -z "$LAST_TAG" ]; then
LAST_TAG="v0.0.0"
fi
VERSION=${LAST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
LAST_COMMIT=$(git log -1 --pretty=%s)
if [[ "$LAST_COMMIT" == major:* ]]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [[ "$LAST_COMMIT" == minor:* ]]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi
echo "new_version=v${MAJOR}.${MINOR}.${PATCH}" >> $GITHUB_OUTPUT
- name: Create Git Tag
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag ${{ steps.version.outputs.new_version }}
git push origin ${{ steps.version.outputs.new_version }}
- name: Create ZIP archive
run: |
zip -r release-${{ steps.version.outputs.new_version }}.zip . \
-x ".git/*" \
-x ".github/workflows/*"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.new_version }}
name: Release ${{ steps.version.outputs.new_version }}
files: |
release-${{ steps.version.outputs.new_version }}.zip