Release Example on Tag #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: tag-release-example | |
on: | |
workflow_dispatch: | |
inputs: | |
example_version: | |
description: 'Version number of release' | |
required: true | |
jobs: | |
# Check the rust formatting | |
format: | |
name: rust-format | |
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-example: | |
name: tag-release example | |
runs-on: ubuntu-latest | |
needs: format | |
strategy: | |
matrix: | |
RUST: [stable] | |
TARGET: | |
- x86_64-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 snapcraft-rust-example-${{ matrix.TARGET }}.tar.gz --directory=target/${{ matrix.TARGET }}/release snapcraft-rust-example | |
- name: Generate SHA checksum | |
run: shasum -a 256 -U snapcraft-rust-example-${{ matrix.TARGET }}.tar.gz > snapcraft-rust-example-${{ matrix.TARGET }}.sha | |
- name: Generate MD5 checksum | |
run: md5sum --tag snapcraft-rust-example-${{ matrix.TARGET }}.tar.gz > snapcraft-rust-example-${{ matrix.TARGET }}.md5 | |
- name: Upload the artifact with the workflow run | |
uses: actions/upload-artifact@v3 | |
with: | |
name: snapcraft-rust-example-${{ matrix.TARGET }}-${{ github.event.inputs.example_version }} | |
path: snapcraft-rust-example-${{ matrix.TARGET }}.* | |
retention-days: 1 | |
# Package the artifacts as a release package | |
tag-release-example-package: | |
name: Package the tag-release example | |
runs-on: ubuntu-latest | |
permissions: write-all | |
needs: [tag-release-example] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download all release artifacts from the workflow | |
uses: actions/download-artifact@v3 | |
- name: Create Example Release | |
uses: marvinpinto/action-automatic-releases@latest | |
with: | |
automatic_release_tag: "${{ github.event.inputs.example_version }}" | |
title: "Release ${{ github.event.inputs.example_version }}" | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
prerelease: false | |
files: | | |
LICENSE | |
**/snapcraft-rust-example-*.* | |
# Kick off the workflow in the snap repo (a1ecbr0wn/snapcraft) 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-example] | |
steps: | |
- name: Repository Dispatch | |
uses: benc-uk/workflow-dispatch@v1 | |
with: | |
token: ${{ secrets.PAT }} | |
repo: a1ecbr0wn/snapcraft | |
ref: refs/heads/main | |
workflow: snap.yml | |
inputs: '{ "snap_version": "${{ github.event.inputs.example_version }}" }' |