name: Bump version, create new tag and release
on:
push:
branches:
- "main"
jobs:
get_version:
name: Get version
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, '[RELEASE]')"
outputs:
new_tag: ${{ steps.bump_version.outputs.new_tag }}
part: ${{ steps.bump_version.outputs.part }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Get version from PR
id: bump_version
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DEFAULT_BUMP: none
DRY_RUN: true
bump_version:
name: Commit new version
runs-on: ubuntu-latest
needs: get_version
if: needs.get_version.outputs.part != ''
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: "0"
- name: Cache cargo release and rust install steps
id: cache-release
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/target/
key: ${{ runner.os }}-cargo-release
- name: Install cargo-release
uses: actions-rs/cargo@v1
if: steps.cache-release.outputs.cache-hit != 'true'
with:
command: install
args: cargo-release
- name: Setup Git info
run: |
git config user.name "tom pridham"
git config user.email "pridham.tom@gmail.com"
- name: Create tag and update Cargo.toml
uses: actions-rs/cargo@v1
with:
command: release
args: ${{ needs.get_version.outputs.part }} --execute --no-confirm --no-publish