Skip to content

Release Binaries on Tag #65

Release Binaries on Tag

Release Binaries on Tag #65

Workflow file for this run

---
name: Release Binaries on Tag
on:
push:
tags:
- "v*"
workflow_dispatch:
jobs:
# Check the rust formatting
format:
name: Rust Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust Toolchain setup
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Format Check
uses: mbrobbel/rustfmt-check@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Build the Linux release artifacts
tag-release-build-linux:
name: Build tag as a release - Linux
runs-on: ubuntu-latest
needs: format
strategy:
matrix:
RUST: [stable]
TARGET:
- x86_64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- aarch64-unknown-linux-gnu
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Toolchain setup
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.RUST }}
target: ${{ matrix.TARGET }}
- name: Cross setup
run: cargo install cross
- name: Test
run: cross test --target=${{ matrix.TARGET }}
- name: Build
run: cross build --release --target=${{ matrix.TARGET }}
- name: Package Release
run: tar cvzf bcd-${{ matrix.TARGET }}.tar.gz --directory=target/${{ matrix.TARGET }}/release bookmark-cd
- name: Generate SHA checksum
run: shasum -a 256 -U bcd-${{ matrix.TARGET }}.tar.gz > bcd-${{ matrix.TARGET }}.sha
- name: Generate MD5 checksum
run: md5sum --tag bcd-${{ matrix.TARGET }}.tar.gz > bcd-${{ matrix.TARGET }}.md5
- name: Upload the artifact with the workflow run
uses: actions/upload-artifact@v3
with:
name: bcd-${{ matrix.TARGET }}-${{ github.ref_name }}
path: bcd-${{ matrix.TARGET }}.*
retention-days: 1
# Build the MacOS release artifacts
tag-release-build-macos:
name: Build tag as a release - MacOS
runs-on: macos-latest
needs: format
strategy:
matrix:
RUST: [stable]
TARGET:
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Toolchain setup
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.RUST }}
target: ${{ matrix.TARGET }}
- name: Cross setup
run: cargo install cross
- name: Test
run: cross test
- name: Build
run: cross build --release --target=${{ matrix.TARGET }}
- name: Package Release
run: tar cvzf bcd-${{ matrix.TARGET }}.tar.gz --directory=target/${{ matrix.TARGET }}/release bookmark-cd
- name: Generate SHA checksum
run: shasum -a 256 -U bcd-${{ matrix.TARGET }}.tar.gz > bcd-${{ matrix.TARGET }}.sha
- name: Generate MD5 checksum
run: md5 bcd-${{ matrix.TARGET }}.tar.gz > bcd-${{ matrix.TARGET }}.md5
- name: Upload the artifact with the workflow run
uses: actions/upload-artifact@v3
with:
name: bcd-${{ matrix.TARGET }}-${{ github.ref_name }}
path: bcd-${{ matrix.TARGET }}.*
retention-days: 1
# Publishing to crates.io - this will be skipped if the tag as a '-' in it for testing purposes
tag-release-publish:
name: Publish tag as a release
runs-on: ubuntu-latest
needs: [tag-release-build-linux, tag-release-build-macos]
if: github.ref_type == 'tag' && ( contains(github.ref_name, '-') == false )
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Publish Application to crates.io
env:
CARGO_REGISTRY_TOKEN: "${{ secrets.CRATES_TOKEN }}"
run: cargo publish
# Package the artifacts as a release package
tag-release-package:
name: Package tag as a release
runs-on: ubuntu-latest
needs: [tag-release-build-linux, tag-release-build-macos]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download all release artifacts from the workflow
uses: actions/download-artifact@v3
- name: Create CLI Release
uses: softprops/action-gh-release@v1
with:
tag_name: "${{ github.ref_name }}"
name: "Release ${{ github.ref_name }}"
token: "${{ secrets.GITHUB_TOKEN }}"
files: |
LICENSE
**/bcd-*.*
# Kick off the workflow in the tap repo (a1ecbr0wn/homebrew-bcd) that will generate the homebrew formula
generate-formula:
name: Initiate the generation of homebrew formula
runs-on: ubuntu-latest
needs: [tag-release-build-linux, tag-release-build-macos]
steps:
- name: Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PAT }}
repo: a1ecbr0wn/homebrew-bcd
ref: refs/heads/main
workflow: tap.yml
inputs: '{ "tap_version": "${{ github.ref_name }}" }'
# Kick off the workflow in the snap repo (a1ecbr0wn/snapcraft-bcd) that will generate the snapcraft yaml file
generate-snap:
name: Initiate the generation of the snapcraft yaml file
runs-on: ubuntu-latest
needs: [tag-release-build-linux, tag-release-build-macos]
steps:
- name: Repository Dispatch
uses: benc-uk/workflow-dispatch@v1
with:
token: ${{ secrets.PAT }}
repo: a1ecbr0wn/snapcraft-bcd
ref: refs/heads/main
workflow: snap.yml
inputs: '{ "snap_version": "${{ github.ref_name }}" }'