Skip to content

Commit

Permalink
Create new releases when the version in Cargo.toml is updated
Browse files Browse the repository at this point in the history
  • Loading branch information
riquito committed May 31, 2020
1 parent 452c460 commit 8753bbf
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,54 @@
name: Build, bump tag version and release

defaults:
run:
shell: bash

on:
push:
branches:
- master

jobs:
check-if-needs-release:
name: Check if needs release
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.is-new-version.outputs.result }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: "0"

- name: Get version from Cargo.toml
id: version-by-cargo
run: |
echo "::set-output name=version::v$(cargo metadata --offline --no-deps --format-version=1 | jq --raw-output '.packages[0].version')"
- name: Is already tagged at latest version?
id: is-new-version
run: |
echo "::set-output name=result::$(test $(git tag --list ${{ steps.version-by-cargo.outputs.version }}) && echo "" || echo ${{ steps.version-by-cargo.outputs.version }})"
release:
needs: check-if-needs-release
if: needs.check-if-needs-release.outputs.new_version != ''
name: Build and Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: "0"

- name: Build project
run: cargo build --release --locked
- name: Bump version and push tag/create release point
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: true
INITIAL_VERSION: 0.1.0
CUSTOM_TAG: ${{ needs.check-if-needs-release.outputs.new_version }}
id: bump_version

- name: Upload binary to release
Expand Down

0 comments on commit 8753bbf

Please sign in to comment.