Skip to content

Release

Release #7

Workflow file for this run

name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
bump:
description: 'Version bump type (overrides conventional commit detection)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
jobs:
prepare:
name: Prepare Release PR
runs-on: ubuntu-latest
if: |
github.repository_owner == 'G-Core' &&
github.event_name == 'workflow_dispatch'
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Determine version bump type
id: bump
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
BUMP="${{ github.event.inputs.bump }}"
echo "Manual trigger — using bump: $BUMP"
else
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
COMMITS=$(git log --pretty=format:"%s%n%b")
else
COMMITS=$(git log --pretty=format:"%s%n%b" "${LAST_TAG}..HEAD")
fi
BUMP="patch"
if echo "$COMMITS" | grep -qE "(BREAKING CHANGE|^[a-z]+(\(.+\))?!:)"; then
BUMP="major"
elif echo "$COMMITS" | grep -qE "^feat(\(.+\))?:"; then
BUMP="minor"
fi
echo "Detected bump from commits: $BUMP"
fi
echo "bump=$BUMP" >> "$GITHUB_OUTPUT"
- name: Bump workspace version
id: version
run: |
CURRENT=$(grep '^version' Cargo.toml | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
case "${{ steps.bump.outputs.bump }}" in
major) MAJOR=$((MAJOR+1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR+1)); PATCH=0 ;;
patch) PATCH=$((PATCH+1)) ;;
esac
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
sed -i "s/^version = \"[0-9]*\.[0-9]*\.[0-9]*\"/version = \"$NEW_VERSION\"/" Cargo.toml
cargo update --workspace
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "New version: v$NEW_VERSION"
- name: Commit version bump to release branch
run: |
BRANCH="release/v${{ steps.version.outputs.version }}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add Cargo.toml Cargo.lock
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}"
git push origin "$BRANCH"
- name: Create release PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--base main \
--head "release/v${{ steps.version.outputs.version }}" \
--title "chore: bump version to ${{ steps.version.outputs.version }}" \
--body "Automated version bump for release v${{ steps.version.outputs.version }}"
publish:
name: Publish Release
runs-on: ubuntu-latest
if: |
github.repository_owner == 'G-Core' &&
github.event_name == 'push' &&
(startsWith(github.event.head_commit.message, 'chore: bump version') ||
contains(github.event.head_commit.message, 'release/v'))
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-wasip1
- name: Get version from Cargo.toml
id: version
run: |
VERSION=$(grep '^version' Cargo.toml | head -1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "Publishing version: v$VERSION"
- name: Tag release
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.version }}"
git push origin "v${{ steps.version.outputs.version }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ steps.version.outputs.version }}"
generate_release_notes: true
- name: Publish fastedge-derive to crates.io
run: cargo publish -p fastedge-derive
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Wait for crates.io index to update
run: sleep 30
- name: Publish fastedge to crates.io
run: cargo publish -p fastedge
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}