Skip to content

Commit

Permalink
build: update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
azzamsa committed Oct 7, 2024
1 parent 39ac30c commit ca54b00
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 255 deletions.
58 changes: 20 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: CI

env:
MIN_SUPPORTED_RUST_VERSION: "1.67.0"

on: [push, pull_request]

jobs:
Expand All @@ -11,25 +8,27 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy, rustfmt

- name: Install latest just release
uses: taiki-e/install-action@just
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@dprint
- uses: taiki-e/install-action@v2
with:
tool: typos-cli

- name: Install latest dprint release
uses: taiki-e/install-action@dprint
- name: Show version information
shell: bash
run: |
just -V
dprint --version
- name: Ensure `fmt` has been run
run: just fmt-check

- name: Ensure MSRV is set in `clippy.toml`
run: grep "^msrv = \"${{ env.MIN_SUPPORTED_RUST_VERSION }}\"\$" clippy.toml

- name: Run clippy
run: just lint

Expand All @@ -38,21 +37,14 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
uses: actions/checkout@v3

- name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
uses: actions/checkout@v4

- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Install latest dprint release
uses: taiki-e/install-action@just
- uses: taiki-e/install-action@just
- uses: taiki-e/install-action@nextest

- name: Run tests
run: just test
- run: just test

build:
name: Build for ${{ matrix.build }}
Expand All @@ -72,20 +64,15 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v3

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}

- name: Show version information
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
rustc --version
cargo --version
- name: Install musl-tools
if: matrix.target == 'x86_64-unknown-linux-musl'
Expand All @@ -94,10 +81,5 @@ jobs:
sudo apt-get install -y --no-install-recommends \
--allow-unauthenticated musl-tools
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}-${{ matrix.target }}

- name: Build
run: cargo build --release --target ${{ matrix.target }}
73 changes: 57 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,55 @@ on:
push:
tags:
- 'v*'
env:
PROJECT_NAME: dryip

jobs:
release:
name: Release
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-22.04
steps:

- name: Checkout
uses: actions/checkout@v3
with:
# it is a must!
fetch-depth: 0

- name: Set the release version
shell: bash
run: |
echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
echo ${{ env.RELEASE_VERSION }}
- name: Checkout current tag
shell: bash
run: |
git checkout v${{ env.RELEASE_VERSION }}
- name: Generate a changelog
uses: orhun/git-cliff-action@v2
id: git-cliff
with:
config: configs/cliff.toml
args: -vv --strip header --current
env:
OUTPUT: CHANGELOG.md.tmp

- name: Print the changelog
run: cat "${{ steps.git-cliff.outputs.changelog }}"

- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GH_TOKEN }}
name: "v${{ env.RELEASE_VERSION }}"
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
generate_release_notes: true
body_path: "${{ steps.git-cliff.outputs.changelog }}"

publish:
name: Publish
runs-on: ubuntu-22.04
steps:
- name: Checkout source code
Expand All @@ -25,15 +70,11 @@ jobs:
- name: Extract crate information
shell: bash
run: |
echo "PROJECT_NAME=dryip" >> $GITHUB_ENV
echo "PROJECT_NAME=${{ env.PROJECT_NAME }}" >> $GITHUB_ENV
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy, rustfmt

- name: Cache
uses: Swatinem/rust-cache@v2
target: ${{ matrix.target }}

- name: Create tarball
id: package
Expand All @@ -50,7 +91,7 @@ jobs:
# Source
cp -r "src" "$ARCHIVE_DIR"
# README, LICENSE and CHANGELOG files
cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "CHANGELOG.md" "$ARCHIVE_DIR"
cp "README.md" "LICENSE" "CHANGELOG.md" "$ARCHIVE_DIR"
# Compress
pushd "${PKG_STAGING}/" >/dev/null
Expand All @@ -61,10 +102,10 @@ jobs:
echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT
- name: Release
uses: svenstaro/upload-release-action@v2
uses: softprops/action-gh-release@v1
with:
repo_token: ${{ secrets.GH_TOKEN }}
file: ${{ steps.package.outputs.PKG_PATH }}
tag: ${{ github.ref }}
asset_name: ${{ steps.package.outputs.PKG_NAME }}
release_name: "v${{ env.RELEASE_VERSION }}"
token: ${{ secrets.GH_TOKEN }}
name: "v${{ env.RELEASE_VERSION }}"
files: ${{ steps.package.outputs.PKG_NAME }}
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
generate_release_notes: false
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ description = "Short 🩸 Rust 🦀 code snippets for inspiration."

[dependencies]
itertools = "0.10.5"

[package.metadata.release]
sign-commit = true
sign-tag = true
tag-message = "v{{version}}"
pre-release-commit-message = "v{{version}}"
pre-release-hook = ["just", "_release-prepare", "{{version}}"]
File renamed without changes.
Loading

0 comments on commit ca54b00

Please sign in to comment.