chore(deps): bump actions/upload-artifact from 2 to 4 #685
Workflow file for this run
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: Scotty Workflow | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "**.md" | |
- "docs/**" | |
pull_request: | |
paths-ignore: | |
- "**.md" | |
- "docs/**" | |
jobs: | |
commit-msg: | |
# Commitsar has nothing to check when run directly on master | |
if: github.ref != 'refs/heads/master' | |
name: Commit Linter | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Check commit message format (necessary to generate release changelogs) | |
uses: docker://commitsar/commitsar:latest | |
build-lint: | |
name: Build, Formatter & Linter | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
components: rustfmt, clippy | |
override: true | |
# Cache all the things! | |
- uses: Swatinem/rust-cache@v1 | |
with: | |
key: v1 | |
# Check if the code meets formatting guidelines | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
# Build to see if the code can compile | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --all-targets --all-features | |
# Check if the code has no linter recommendations (clippy can reuse build artifacts, but not the other way around) | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: --all-targets --all-features -- -D clippy::all | |
test: | |
name: Test Matrix | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macOS-latest, windows-latest] | |
rust: [stable, nightly] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: ${{ matrix.rust }} | |
override: true | |
components: rustfmt, clippy | |
# Cache all the things! | |
- uses: Swatinem/rust-cache@v1 | |
with: | |
key: v1 | |
# Run the tests | |
- uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --all | |
# If we tag a release, publish the result to crates.io | |
publish_crate: | |
if: startsWith(github.ref, 'refs/tags/v') | |
name: Publish on crates.io | |
needs: [publish_binaries] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
- run: cargo login $CRATES_IO_TOKEN | |
- run: cargo publish | |
env: | |
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | |
# If we tag a release, build binaries for supported platforms | |
build_binaries: | |
if: startsWith(github.ref, 'refs/tags/v') | |
name: Build release binaries | |
needs: [test] | |
strategy: | |
fail-fast: false | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- x86_64-unknown-linux-musl | |
- x86_64-apple-darwin | |
- x86_64-pc-windows-msvc | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
name: scotty-x86_64-unknown-linux-gnu.tar.gz | |
- target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
name: scotty-x86_64-unknown-linux-musl.tar.gz | |
- target: x86_64-apple-darwin | |
os: macOS-latest | |
name: scotty-x86_64-apple-darwin.tar.gz | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
name: scotty-x86_64-pc-windows-msvc.zip | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
override: true | |
target: ${{ matrix.target }} | |
- name: Install musl tools | |
if: matrix.target == 'x86_64-unknown-linux-musl' | |
run: sudo apt-get install -y musl-tools | |
- name: Build target | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Prepare build artifacts [Windows] | |
if: matrix.os == 'windows-latest' | |
run: | | |
cd target/${{ matrix.target }}/release | |
strip scotty.exe | |
7z a ../../../${{ matrix.name }} scotty.exe | |
cd - | |
- name: Prepare build artifacts [-nix] | |
if: matrix.os != 'windows-latest' | |
run: | | |
cd target/${{ matrix.target }}/release | |
strip scotty | |
tar czvf ../../../${{ matrix.name }} scotty | |
cd - | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.name }} | |
path: ${{ matrix.name }} | |
publish_binaries: | |
if: startsWith(github.ref, 'refs/tags/v') | |
name: Create GitHub Release | |
needs: [build_binaries] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Download releases from github_build | |
uses: actions/download-artifact@v2 | |
with: | |
name: scotty-x86_64-unknown-linux-gnu.tar.gz | |
path: . | |
- name: Download releases from github_build | |
uses: actions/download-artifact@v2 | |
with: | |
name: scotty-x86_64-unknown-linux-musl.tar.gz | |
path: . | |
- name: Download releases from github_build | |
uses: actions/download-artifact@v2 | |
with: | |
name: scotty-x86_64-apple-darwin.tar.gz | |
path: . | |
- name: Download releases from github_build | |
uses: actions/download-artifact@v2 | |
with: | |
name: scotty-x86_64-pc-windows-msvc.zip | |
path: . | |
- name: Generate checksums | |
run: for file in scotty-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done | |
- name: Install go (needed for changelog tool) | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.14 | |
- name: Generate changelog | |
run: | | |
export PATH=${PATH}:$(go env GOPATH)/bin | |
GO111MODULE=on go get github.com/git-chglog/git-chglog/cmd/git-chglog | |
git-chglog -c .github/chglog/config.yml $(git describe --tags) > CHANGELOG.md | |
- name: Create GitHub release ${{ matrix.target }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
scotty-x86_64-unknown-linux-gnu.tar.gz | |
scotty-x86_64-unknown-linux-gnu.tar.gz.sha256 | |
scotty-x86_64-unknown-linux-musl.tar.gz | |
scotty-x86_64-unknown-linux-musl.tar.gz.sha256 | |
scotty-x86_64-apple-darwin.tar.gz | |
scotty-x86_64-apple-darwin.tar.gz.sha256 | |
scotty-x86_64-pc-windows-msvc.zip | |
scotty-x86_64-pc-windows-msvc.zip.sha256 | |
body_path: CHANGELOG.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create homebrew release | |
uses: actions/github-script@v3 | |
with: | |
github-token: ${{secrets.HOMEBREW_REPO_TOKEN}} | |
script: | | |
const fs = require('fs') | |
const macAmd64Sha = fs.readFileSync("scotty-x86_64-apple-darwin.tar.gz.sha256", {encoding: "utf8"}).trim() | |
const macArm64Sha = fs.readFileSync("scotty-arm64-apple-darwin.tar.gz.sha256", {encoding: "utf8"}).trim() | |
const linuxAmd64Sha = fs.readFileSync("scotty-x86_64-unknown-linux-gnu.tar.gz.sha256", {encoding: "utf8"}).trim() | |
github.actions.createWorkflowDispatch({ | |
owner: "wdullaer", | |
repo: "homebrew-scotty", | |
workflow_id: "workflow.yaml", | |
ref: "master", | |
inputs: { | |
"version": context.ref.substring(10), // "refs/tags/".length == 10 | |
"mac-amd64-sha": macAmd64Sha, | |
"mac-arm64-sha": macArm64Sha, | |
"linux-amd64-sha": linuxAmd64Sha | |
} | |
}) |