Skip to content

tag-and-version

tag-and-version #86

name: tag-and-version
on:
push:
branches:
- master
paths:
- "**.rs"
workflow_dispatch:
jobs:
tag:
if: github.actor != 'github-actions[bot]'
name: ${{ github.actor }} authorized build and tag
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Get package version
run: |
PACKAGE_VERSION=$(awk -F ' = ' '$1 ~ /version/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml)
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Generate new version
id : bump_version
uses: christian-draeger/increment-semantic-version@1.1.0
with:
current-version: ${{ env.PACKAGE_VERSION }}
- name: Set package version
run: |
sed -i '3s/.*/version = "${{ steps.bump_version.outputs.next-version }}"/' Cargo.toml
if [[ $? != 0 ]]; then
echo "ERROR: Failed to update the version number in Cargo.toml" >&2
exit 1
else
echo "Successfully updated the version number in Cargo.toml to ${{ steps.bump_version.outputs.next-version }}"
fi
- name: Commit
env:
GH_TOKEN: ${{ secrets.MY_TOKEN }}
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git tag v"${{ steps.bump_version.outputs.next-version }}"
git commit -am "chore: bump version to ${{ steps.bump_version.outputs.next-version }}"
git push origin ${{ github.ref }} --follow-tags