Skip to content

feat(github-actions): ensure single tag for automated commits and upd… #1

feat(github-actions): ensure single tag for automated commits and upd…

feat(github-actions): ensure single tag for automated commits and upd… #1

name: Release & Publish Workflow
on:
push:
branches:
- main
jobs:
check-tag:
runs-on: ubuntu-latest
outputs:
tag_exists: ${{ steps.tag_check.outputs.tag_exists }}
steps:
- uses: actions/checkout@v2
- name: Check for Tag
id: tag_check
run: |
TAG=$(git tag --points-at HEAD)
if [ -z "$TAG" ]; then
echo "tag_exists=false" >> $GITHUB_ENV
echo "::set-output name=tag_exists::false"
else
echo "tag_exists=true" >> $GITHUB_ENV
echo "::set-output name=tag_exists::true"
fi
shell: bash
build-and-release:
needs: check-tag
if: needs.check-tag.outputs.tag_exists == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Test Build
run: cargo build --release
- name: Publish to Cargo
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Build Linux Executable
run: cargo build --release --target x86_64-unknown-linux-gnu
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: target/x86_64-unknown-linux-gnu/release/turbocommit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}