Skip to content

Commit

Permalink
Create release.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Eskander authored Nov 3, 2024
1 parent 158af61 commit 105ddc8
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
pull_request:
types:
- closed

jobs:
version-bump:
if: |
github.event.pull_request.merged == true &&
contains(github.event.pull_request.title, 'justarchinet/archisteamfarm')
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Extract current version and PR title
id: extract
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
# Extract current version from config.yaml
CURRENT_VERSION=$(grep "version:" src/config.yaml | sed 's/.*: "\(.*\)"/\1/')
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
# Calculate new version (bump minor)
MAJOR=$(echo "$CURRENT_VERSION" | cut -d. -f1)
MINOR=$(echo "$CURRENT_VERSION" | cut -d. -f2)
NEW_MINOR=$((MINOR + 1))
NEW_VERSION="$MAJOR.$NEW_MINOR"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
# Clean PR title (remove backticks and "in /src")
CLEAN_TITLE=$(echo "$PR_TITLE" | sed 's/`//g' | sed 's/ in \/src$//')
echo "pr_title=${CLEAN_TITLE}" >> $GITHUB_OUTPUT
- name: Update version in config.yaml
run: |
sed -i 's/version: ".*"/version: "${{ steps.extract.outputs.new_version }}"/' src/config.yaml
- name: Update CHANGELOG.md
run: |
# Prepare new entry
NEW_ENTRY="# ${{ steps.extract.outputs.new_version }}\n- ${{ steps.extract.outputs.pr_title }}\n"
# Prepend new entry to CHANGELOG.md
echo -e "$NEW_ENTRY$(cat src/CHANGELOG.md)" > src/CHANGELOG.md
- name: Commit and push changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add src/config.yaml src/CHANGELOG.md
git commit -m "Bump version to ${{ steps.extract.outputs.new_version }}"
git push

0 comments on commit 105ddc8

Please sign in to comment.