Skip to content

Delete rc branch

Delete rc branch #15

Workflow file for this run

name: Release (Rust)
on:
push:
tags:
- 'rs/v*-rc'
jobs:
release:
name: Release
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Release Info
id: release_info
run: |
RELEASE_TAG=${GITHUB_REF#refs/tags/}
VERSION=${RELEASE_TAG#rs/v}
VERSION="${VERSION%-rc}"
if [[ ! $VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "'$VERSION' is not a valid semver version"
exit 1
fi
# Fetch commit details using the GitHub API
COMMIT_DETAILS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/$RELEASE_TAG")
# Extract the author's name and email
AUTHOR_NAME=$(echo "$COMMIT_DETAILS" | jq -r .commit.author.name)
AUTHOR_EMAIL=$(echo "$COMMIT_DETAILS" | jq -r .commit.author.email)
echo "Author Name: $AUTHOR_NAME"
echo "Author Email: $AUTHOR_EMAIL"
echo "Version: $VERSION"
echo "author_name=$AUTHOR_NAME" >> $GITHUB_OUTPUT
echo "author_email=$AUTHOR_EMAIL" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Say Hi
run: |
echo "We are about to release: ${{ steps.release_info.outputs.version }}"
- name: Set Workspace Version
run: |
sed -i "s/^version = \".*\"/version = \"${{ steps.release_info.outputs.version }}\"/" Cargo.toml
- name: Update Workspace Dependencies
run: |
cargo update
- name: Run Tests
run: |
cargo test
- name: Commit Changes
run: |
RC_BRANCH="rc/rs/v${{ steps.release_info.outputs.version }}"
#git config --global user.name "${{ steps.release_info.outputs.author_name }}"
#git config --global user.email "${{ steps.release_info.outputs.author_email }}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "$RC_BRANCH"
git add Cargo.toml
git add Cargo.lock
git commit -m "build: update version to v${{ steps.release_info.outputs.version }}"
git push origin "$RC_BRANCH"
git tag rs/v${{ steps.release_info.outputs.version }}
git push origin rs/v${{ steps.release_info.outputs.version }}
git push --delete origin "${GITHUB_REF#refs/tags/}"
git checkout main
git merge --squash "$RC_BRANCH"
git commit -m "chore: sync release v${{ steps.release_info.outputs.version }}"
git push origin main
git branch -d "$RC_BRANCH"
git push origin --delete "$RC_BRANCH"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}