Skip to content

Add workflows

Add workflows #1

Workflow file for this run

name: Auto Release for Main Branch
on:
push:
branches:
- main # Trigger on pushes to the main branch
pull_request:
branches:
- main # Trigger on pull requests targeting the main branch
jobs:
publish-release:
name: Publish Release
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v3
# Step 2: Extract Version from `pv_opt.py`
- name: Extract Version
id: extract_version
run: |
# Extract the VERSION variable from pv_opt.py
VERSION=$(grep -oP '(?<=^VERSION = ")[^"]+' apps/pv_opt/pv_opt.py)
if [ -z "$VERSION" ]; then
echo "Error: VERSION not found in apps/pv_opt/pv_opt.py"
exit 1
fi
echo "VERSION=$VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
echo "::set-output name=version::$VERSION"
# Step 3: Create GitHub Release
- name: Create GitHub Release
if: github.event_name == 'push' || github.event.pull_request.merged == true
uses: actions/create-release@v1
with:
tag_name: "v${{ env.version }}"
release_name: "Release v${{ env.version }}"
body: |
## Changes
This release was automatically generated from the `main` branch.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}