Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/scripts/extract-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -euo pipefail

BRANCH="$1"
VERSION="${BRANCH#release/v}"

if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Invalid version format: $BRANCH (expected release/vX.Y.Z)" >&2
exit 1
fi

echo "$VERSION"
28 changes: 22 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
name: Pack and Publish
runs-on: ubuntu-latest
needs: test
outputs:
version: ${{ steps.version.outputs.value }}
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -44,12 +46,7 @@ jobs:
- name: Extract version from branch name
id: version
run: |
BRANCH="${GITHUB_REF#refs/heads/}"
VERSION="${BRANCH#release/v}"
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "Invalid version format in branch name: $BRANCH (expected release/vX.Y.Z)"
exit 1
fi
VERSION=$(bash .github/scripts/extract-version.sh "${GITHUB_REF#refs/heads/}")
echo "value=$VERSION" >> "$GITHUB_OUTPUT"

- name: Setup .NET
Expand All @@ -74,3 +71,22 @@ jobs:
--api-key ${{ secrets.NUGET_API_KEY }}
--source https://api.nuget.org/v3/index.json
--skip-duplicate

merge:
name: Open PR to Main
runs-on: ubuntu-latest
needs: publish
permissions:
pull-requests: write
steps:
- name: Create PR and enable auto-merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_URL=$(gh pr create \
--repo "$GITHUB_REPOSITORY" \
--title "Release v${{ needs.publish.outputs.version }}" \
--body "Automated release PR for v${{ needs.publish.outputs.version }}. Package published to NuGet successfully." \
--base main \
--head "${{ github.ref_name }}")
gh pr merge "$PR_URL" --merge --auto
33 changes: 33 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tag Release

on:
pull_request:
types: [closed]
branches:
- main

jobs:
tag:
name: Create Release Tag
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0

- name: Extract version from branch name
id: version
run: |
VERSION=$(bash .github/scripts/extract-version.sh "${{ github.event.pull_request.head.ref }}")
echo "value=$VERSION" >> "$GITHUB_OUTPUT"

- name: Create and push tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "v${{ steps.version.outputs.value }}"
git push origin "v${{ steps.version.outputs.value }}"
Loading