Skip to content

Commit

Permalink
Update workflow actions to latest (#121)
Browse files Browse the repository at this point in the history
Fix various deprecation warnings. The `actions-rs` and
`actions/*release*` workflows are unmaintained; replace the former with
manual Rust commands and the latter with a substitute.

Use generic content type for uploaded artifacts. This avoids the need to
run the release step once per artifact, and the content types don't seem
to be attached to the final download anyway.

Also drop monthly run of Rust workflow. We already have the `cargo
update` PR to ensure there's a monthly CI run. Removing the timer from
the Rust job allows it to be enabled in forks for pre-PR testing without
also running it periodically there.
  • Loading branch information
bgilbert authored Aug 11, 2023
1 parent 7c09f05 commit 671b323
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 105 deletions.
117 changes: 52 additions & 65 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
tags:
- 'v*'

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always

permissions:
contents: write

Expand All @@ -13,18 +17,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Install musl
uses: actions-rs/toolchain@v1
with:
target: x86_64-unknown-linux-musl
uses: actions/checkout@v3
- name: Install toolchain
run: |
rustup toolchain install stable --profile minimal --no-self-update \
--target x86_64-unknown-linux-musl
rustup default stable
echo "Installed:"
cargo --version
rustc --version --verbose
- name: Build release (Linux)
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features --target x86_64-unknown-linux-musl
run: cargo build --release --all-features --target x86_64-unknown-linux-musl
- run: strip target/x86_64-unknown-linux-musl/release/gptman
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: binary-linux
path: target/x86_64-unknown-linux-musl/release/gptman
Expand All @@ -33,13 +38,19 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install toolchain
shell: bash
run: |
rustup toolchain install stable --profile minimal --no-self-update \
--target x86_64-pc-windows-msvc
rustup default stable
echo "Installed:"
cargo --version
rustc --version --verbose
- name: Build release (Windows)
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features --target=x86_64-pc-windows-msvc
- uses: actions/upload-artifact@v2
run: cargo build --release --all-features --target=x86_64-pc-windows-msvc
- uses: actions/upload-artifact@v3
with:
name: binary-windows
path: target/x86_64-pc-windows-msvc/release/gptman.exe
Expand All @@ -48,13 +59,17 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install toolchain
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
echo "Installed:"
cargo --version
rustc --version --verbose
- name: Build release (OSX)
uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features
- uses: actions/upload-artifact@v2
run: cargo build --release --all-features
- uses: actions/upload-artifact@v3
with:
name: binary-osx
path: target/release/gptman
Expand All @@ -63,56 +78,28 @@ jobs:
needs: [build-linux, build-windows, build-osx-x86]
runs-on: ubuntu-latest
steps:
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: binary-linux
path: binary-linux
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: binary-windows
path: binary-windows
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: binary-osx
path: binary-osx
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: gptman release ${{ steps.get_version.outputs.VERSION }}
draft: false
prerelease: false
- name: Upload Release Asset Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: binary-linux/gptman
asset_name: gptman-${{ steps.get_version.outputs.VERSION }}-linux-x86_64
asset_content_type: application/x-pie-executable
- name: Upload Release Asset Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: binary-windows/gptman.exe
asset_name: gptman-${{ steps.get_version.outputs.VERSION }}-win-x86_64.exe
asset_content_type: application/x-dosexec
- name: Upload Release Asset OSX
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Arrange artifacts
run: |
mkdir artifacts
mv binary-linux/gptman "artifacts/gptman-${{ github.ref_name }}-linux-x86_64"
mv binary-windows/gptman.exe "artifacts/gptman-${{ github.ref_name }}-win-x86_64.exe"
mv binary-osx/gptman "artifacts/gptman-${{ github.ref_name }}-osx-x86_64"
- uses: ncipollo/release-action@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: binary-osx/gptman
asset_name: gptman-${{ steps.get_version.outputs.VERSION }}-osx-x86_64
asset_content_type: application/x-mach-binary
artifactErrorsFailBuild: true
artifacts: "artifacts/*"
body: gptman release ${{ github.ref_name }}
makeLatest: true
name: Release ${{ github.ref_name }}
43 changes: 15 additions & 28 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ name: Rust
on:
push:
branches: [ main ]
schedule:
- cron: 0 0 1 * *
pull_request:
branches: [ main ]

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always

jobs:
Expand All @@ -34,43 +33,31 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Select Rust version
- name: Install toolchain
shell: bash
run: |
RUST_VER="${{ matrix.rust }}"
if [ "$RUST_VER" = msrv ]; then
RUST_VER=$(cargo metadata --format-version 1 --no-deps | \
ver="${{ matrix.rust }}"
if [ "$ver" = msrv ]; then
ver=$(cargo metadata --format-version 1 --no-deps | \
jq -r '.packages[0].rust_version')
echo "MSRV: $RUST_VER"
fi
echo "RUST_VER=$RUST_VER" >> $GITHUB_ENV
rustup toolchain install "$ver" --profile minimal --no-self-update
rustup default "$ver"
echo "Installed:"
cargo --version
rustc --version --verbose
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VER }}
default: true
override: true

- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2

- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --workspace ${{ matrix.rust-args }}
run: cargo test --workspace ${{ matrix.rust-args }}

- name: rustfmt
if: github.event_name == 'pull_request' && matrix.lint
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: cargo fmt --all -- --check

- name: clippy
if: github.event_name == 'pull_request' && matrix.lint
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all --tests --all-features -- -D warnings
run: cargo clippy --all --tests --all-features -- -D warnings
23 changes: 12 additions & 11 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
workflow_dispatch:

env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always

permissions:
Expand All @@ -18,23 +19,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
uses: actions/checkout@v3

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true
- name: Install toolchain
run: |
rustup toolchain install stable --profile minimal --no-self-update
rustup default stable
echo "Installed:"
cargo --version
rustc --version --verbose
- uses: Swatinem/rust-cache@v1
- uses: Swatinem/rust-cache@v2

- name: cargo update
uses: actions-rs/cargo@v1
with:
command: update
run: cargo update

- name: Open pull request
uses: peter-evans/create-pull-request@v4.0.3
uses: peter-evans/create-pull-request@v5
with:
branch: cargo-update
title: "cargo update"
Expand Down
1 change: 0 additions & 1 deletion rust-toolchain

This file was deleted.

0 comments on commit 671b323

Please sign in to comment.