add user info #9
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*' | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Extract Release Info | |
id: release_info | |
run: | | |
RELEASE_TAG=${GITHUB_REF#refs/tags/} | |
VERSION=${RELEASE_TAG#rs/v} | |
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: Update Workspace Dependencies | |
run: | | |
cargo update | |
- name: Set Workspace Version | |
run: | | |
sed -i "s/^version = \".*\"/version = \"${{ steps.release_info.outputs.version }}\"/" Cargo.toml | |
- name: Run Tests | |
run: | | |
cargo test | |
- name: Commit Changes | |
run: | | |
git config --global user.name "${{ steps.release_info.outputs.author_name }}" | |
git config --global user.email "${{ steps.release_info.outputs.author_email }}" | |
git checkout -b releases/rs/v${{ steps.release_info.outputs.version }} | |
git add Cargo.toml | |
git add Cargo.lock | |
git commit -m "build: update version to v${{ steps.release_info.outputs.version }}" | |
git push origin releases/rs/v${{ steps.release_info.outputs.version }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |