Release Binary #2
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: Release Binary | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag to release' | |
required: true | |
jobs: | |
build-artifacts: | |
runs-on: ubuntu-latest | |
name: Build Artifacts | |
env: | |
binary_name: git-diff | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry- | |
- name: Cache cargo index | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-index- | |
- name: Cache cargo build | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- name: Build | |
run: cargo build --release | |
- name: Create Archive Folder | |
run: mkdir ${{ runner.os }} | |
- name: Copy Artifact | |
run: cp target/release/${{ env.binary_name }} ${{ runner.os }} | |
- name: Create Tar Archive | |
run: tar -czf ${{ runner.os }}.tgz ${{ runner.os }} | |
- name: Store Archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ runner.os }} | |
path: ${{ runner.os }}.tgz | |
create-release: | |
needs: [build-artifacts] | |
runs-on: ubuntu-latest | |
name: Create Release | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "Linux/Linux.tgz" | |
tag: ${{ github.event.inputs.tag }} |