build(github-actions): use same actions as tmux-backup

This commit is contained in:
graelo 2022-11-07 09:49:13 +01:00
parent afa36d0c8f
commit 2c5c0f391c
6 changed files with 415 additions and 149 deletions

View file

@ -1,74 +0,0 @@
name: CI
on:
push:
branches:
- staging
- trying
jobs:
test_linux:
name: Test on Linux
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.60.0, stable, beta, nightly]
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Checkout
uses: actions/checkout@v2
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
run: ./ci/test_full.sh
test_macOS:
name: Test on macOS 11
runs-on: macos-11
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: aarch64-apple-darwin
- name: Checkout
uses: actions/checkout@v2
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
run: ./ci/test_full.sh
# uses: actions-rs/cargo@v1
# with:
# command: test
# args: --target aarch64-apple-darwin --all-features
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0
profile: minimal
override: true
components: rustfmt
- name: Checkout
uses: actions/checkout@v2
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

89
.github/workflows/essentials.yml vendored Normal file
View file

@ -0,0 +1,89 @@
# Any commit on main & PRs
name: Essentials
on:
push:
branches:
- main
pull_request:
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable]
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
components: rustfmt, clippy
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: ${{ github.event.pull_request.commits }}
- name: Cache crates from crates.io
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: '${{ runner.os }}-cargo-${{ matrix.rust }}-hash-${{ hashFiles(''**/Cargo.lock'') }}'
- name: Lint
run: |
cargo fmt --all -- --check
cargo clippy -- -D warnings
- name: Quality - convco check
run: |
git show-ref
curl -sSfLO https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip
unzip convco-ubuntu.zip
chmod +x convco
./convco check
rm convco
- name: Quality - cargo deny check
run: |
curl -sSfL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.12.2/cargo-deny-0.12.2-x86_64-unknown-linux-musl.tar.gz | tar zx --no-anchored cargo-deny --strip-components=1
chmod +x cargo-deny
mv cargo-deny ~/.cargo/bin/
cargo deny check
- name: Install cargo check tools
timeout-minutes: 20
if: ${{ matrix.rust == 'stable' }}
run: |
cargo install --locked cargo-outdated || true
# cargo install --locked cargo-udeps || true # needs nightly
cargo install --locked cargo-audit || true
cargo install --locked cargo-pants || true
- name: Check
if: ${{ matrix.rust == 'stable' }}
run: |
cargo outdated --exit-code 1
# cargo udeps
rm -rf ~/.cargo/advisory-db
cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602
cargo pants
- name: Build (dev)
run: cargo build --all-features
- name: Build (release)
run: cargo build --all-features --release
- name: Test
run: ./ci/test_full.sh

161
.github/workflows/large-scope.yml vendored Normal file
View file

@ -0,0 +1,161 @@
# Test pre-releases on a larger scope (platforms & versions) to avoid bad surprises.
name: Large scope
on:
push:
branches:
- staging
jobs:
test-versions:
name: Test version compatibility on Linux
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.60.0, beta, nightly]
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
components: rustfmt, clippy
- name: Checkout
uses: actions/checkout@v3
- name: Cache crates from crates.io
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: '${{ runner.os }}-cargo-${{ matrix.rust }}-hash-${{ hashFiles(''**/Cargo.lock'') }}'
- name: Lint
run: |
cargo fmt --all -- --check
cargo clippy -- -D warnings
# - name: Install cargo check tools
# timeout-minutes: 20
# if: ${{ matrix.rust == 'stable' }}
# run: |
# cargo install --locked cargo-outdated || true
# # cargo install --locked cargo-udeps || true # needs nightly
# cargo install --locked cargo-audit || true
# cargo install --locked cargo-pants || true
# - name: Check
# if: ${{ matrix.rust == 'stable' }}
# run: |
# cargo outdated --exit-code 1
# # cargo udeps
# rm -rf ~/.cargo/advisory-db
# cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602
# cargo pants
- name: Build (dev)
run: cargo build --all-features
- name: Build (release)
run: cargo build --all-features --release
- name: Test
run: ./ci/test_full.sh
test-other-platforms:
name: Test on other platforms with stable
runs-on: '${{ matrix.os }}'
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
type: unix
- os: macos-latest
target: aarch64-apple-darwin
type: unix
- os: windows-latest
target: x86_64-pc-windows-msvc
type: windows
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
target: ${{ matrix.target }}
components: rustfmt, clippy
- name: Checkout
uses: actions/checkout@v3
- name: Cache crates from crates.io
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: '${{ runner.os }}-${{ matrix.target }}-cargo-stable-${{ hashFiles(''**/Cargo.lock'') }}'
- name: Lint
run: |
cargo fmt --all -- --check
cargo clippy -- -D warnings
# - name: Quality - convco check
# run: |
# git show-ref
# curl -sSfLO https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip
# unzip convco-ubuntu.zip
# chmod +x convco
# ./convco check
# rm convco
# shell: bash
# - name: Quality - cargo deny check
# run: |
# curl -sSfL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.12.2/cargo-deny-0.12.2-x86_64-unknown-linux-musl.tar.gz | tar zx --no-anchored cargo-deny --strip-components=1
# chmod +x cargo-deny
# mv cargo-deny ~/.cargo/bin/
# cargo deny check
# shell: bash
- name: Install cargo check tools
timeout-minutes: 20
run: |
cargo install --locked cargo-outdated || true
# cargo install --locked cargo-udeps || true # needs nightly
cargo install --locked cargo-audit || true
cargo install --locked cargo-pants || true
shell: bash
- name: Check
run: |
cargo outdated --exit-code 1
# cargo udeps
rm -rf ~/.cargo/advisory-db
cargo audit --ignore RUSTSEC-2020-0071 # time-rs, but not used by chrono, see https://github.com/chronotope/chrono/issues/602
cargo pants
shell: bash
- name: Build (dev)
run: cargo build --all-features
- name: Build (release)
run: cargo build --all-features --release
- name: Test
run: ./ci/test_full.sh

View file

@ -1,29 +0,0 @@
name: main
on:
push:
branches:
- main
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.60.0, stable]
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Checkout
uses: actions/checkout@v2
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
run: ./ci/test_full.sh

View file

@ -1,46 +0,0 @@
name: PR
on:
pull_request:
jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
rust: [1.60.0, stable]
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Checkout
uses: actions/checkout@v2
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
- name: Test
run: ./ci/test_full.sh
fmt:
name: Format
runs-on: ubuntu-latest
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: 1.60.0
profile: minimal
override: true
components: rustfmt
- name: Checkout
uses: actions/checkout@v2
- name: Check formatting
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

165
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,165 @@
name: Release
on:
push:
tags:
- 'v*'
jobs:
prepare-artifacts:
name: Prepare release artifacts
# if: github.ref == 'refs/heads/main'
runs-on: '${{ matrix.os }}'
strategy:
matrix:
include:
- os: macos-latest
target: aarch64-apple-darwin
rust: stable
suffix: ''
archive_ext: zip
- os: macos-latest
target: x86_64-apple-darwin
rust: stable
suffix: ''
archive_ext: zip
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
rust: stable
suffix: ''
archive_ext: tar.xz
- os: windows-latest
target: x86_64-pc-windows-msvc
rust: stable
suffix: .exe
archive_ext: zip
steps:
- name: Rust install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt, clippy
- name: checkout
uses: actions/checkout@v3
- name: Cache crates from crates.io
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: '${{ runner.os }}-${{ matrix.target }}-cargo-${{ matrix.rust }}-hash-${{ hashFiles(''**/Cargo.lock'') }}'
- name: Build Release
run: cargo build --release
- name: Compress to zip (macOS)
if: ${{ matrix.os == 'macos-latest' }}
run:
zip -A ${{ github.event.repository.name }}-${{ matrix.target }}.${{ matrix.archive_ext }} target/release/${{ github.event.repository.name }}
- name: Compress to zip (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run:
Compress-Archive target/release/${{ github.event.repository.name }}${{ matrix.suffix }} ${{ github.event.repository.name }}-${{ matrix.target }}.${{ matrix.archive_ext }}
- name: Compress to tar.xz (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run:
tar Jcf ${{ github.event.repository.name }}-${{ matrix.target }}.${{ matrix.archive_ext }} target/release/${{ github.event.repository.name }}
- name: List files
run: |
ls -alF .
ls -alF target/release/
shell: bash
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.event.repository.name }}-${{ matrix.target }}.${{ matrix.archive_ext }}
path: ${{ github.event.repository.name }}-${{ matrix.target }}.${{ matrix.archive_ext }}
release:
name: Create a GitHub Release
# if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- prepare-artifacts
steps:
- name: checkout
uses: actions/checkout@v3
with:
# convco needs all history to create the changelog
fetch-depth: 0
- name: Extract version
id: extract-version
run: |
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
- name: Download convco
run: |
git show-ref
curl -sSfLO https://github.com/convco/convco/releases/latest/download/convco-ubuntu.zip
unzip convco-ubuntu.zip
chmod +x convco
- name: Use convco to create the changelog
run: |
./convco changelog --max-versions 1 --include-hidden-sections > CHANGELOG.md
rm convco convco-ubuntu.zip
- uses: actions/download-artifact@v3
with:
name: ${{ github.event.repository.name }}-x86_64-unknown-linux-gnu.tar.xz
- uses: actions/download-artifact@v3
with:
name: ${{ github.event.repository.name }}-aarch64-apple-darwin.zip
- uses: actions/download-artifact@v3
with:
name: ${{ github.event.repository.name }}-x86_64-apple-darwin.zip
- uses: actions/download-artifact@v3
with:
name: ${{ github.event.repository.name }}-x86_64-pc-windows-msvc.zip
- uses: ncipollo/release-action@v1
with:
artifacts: "*.zip,*.tar.xz"
bodyFile: "CHANGELOG.md"
token: ${{ secrets.GITHUB_TOKEN }}
homebrew:
name: Bump Homebrew formula
# if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Extract version
id: extract-version
run: |
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
- uses: mislav/bump-homebrew-formula-action@v2
if: "!contains(github.ref, '-')" # skip prereleases
with:
formula-name: tmux-copyrat
homebrew-tap: graelo/homebrew-tap
# base-branch: main
create-pullrequest: true
download-url: https://github.com/graelo/tmux-copyrat/archive/refs/tags/${{ steps.extract-version.outputs.tag-name }}.tar.gz
commit-message: |
{{formulaName}} {{version}}
Created by https://github.com/mislav/bump-homebrew-formula-action
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}