yet another attempt to remove temp branch #21
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 build | |
cargo test | |
- name: Commit Changes | |
run: | | |
RC_BRANCH="rc/rs/v${{ steps.release_info.outputs.version }}" | |
R_TAG="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 "$R_TAG" | |
git push origin "$R_TAG" | |
git push origin --delete "${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 checkout "$R_TAG" | |
git branch -d "$RC_BRANCH" | |
git push origin --delete "$RC_BRANCH" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: Release v${{ steps.release_info.outputs.version }} (Rust) | |
tag_name: rs/v${{ steps.release_info.outputs.version }} | |
generate_release_notes: true | |
fail_on_unmatched_files: true | |
files: | | |
Cargo.toml | |
target/debug/hello | |
draft: true | |
token: ${{ secrets.GITHUB_TOKEN }} |