build(container): use alpine:3 instead of specific 3.17 #1008
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: Test and Build Rust | |
on: | |
push: | |
pull_request: | |
jobs: | |
rustfmt: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Rust | |
shell: bash -eux {0} | |
run: | | |
rm ~/.cargo/bin/{rustfmt,cargo-fmt} | |
rustup toolchain install stable --profile minimal --component rustfmt | |
rustup default stable | |
- uses: actions/checkout@v3 | |
- run: cargo fmt --check --verbose | |
test: | |
name: Test ${{ matrix.toolchain }} ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
continue-on-error: ${{ matrix.toolchain == 'nightly' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain: | |
- stable | |
os: | |
- ubuntu-latest | |
- macos-latest | |
- windows-latest | |
clippyargs: | |
- -D clippy::pedantic -D warnings | |
features: | |
- --all-features | |
include: | |
# Check future versions and maybe get some glances on soon to be lints | |
- toolchain: beta | |
os: ubuntu-latest | |
features: --all-features | |
clippyargs: -W clippy::pedantic -W clippy::nursery | |
- toolchain: nightly | |
os: ubuntu-latest | |
features: --all-features | |
clippyargs: -W clippy::pedantic | |
steps: | |
- name: Setup Rust | |
shell: bash -eux {0} | |
run: | | |
rustup toolchain install ${{ matrix.toolchain }} --profile minimal --component clippy | |
rustup default ${{ matrix.toolchain }} | |
- uses: actions/checkout@v3 | |
- name: Fetch dependencies | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fetch | |
args: --verbose --locked | |
- name: Check clippy | |
uses: actions-rs/cargo@v1 | |
with: | |
command: clippy | |
args: --verbose --locked --all-targets ${{ matrix.features }} -- ${{ matrix.clippyargs }} | |
- name: Check docs | |
uses: actions-rs/cargo@v1 | |
with: | |
command: doc | |
args: --verbose --locked --no-deps ${{ matrix.features }} | |
- name: Run tests | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --verbose --locked ${{ matrix.features }} | |
prepare-packaging-tools: | |
runs-on: ubuntu-latest | |
permissions: {} | |
steps: | |
- name: Setup Rust | |
shell: bash -eux {0} | |
run: | | |
rustup toolchain install stable --profile minimal | |
rustup default stable | |
- name: Cache packaging tools | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-cargo-packaging-tools | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/.crates* | |
- name: Install packaging tools | |
run: cargo install cargo-deb cargo-generate-rpm | |
github-release: | |
name: Release ${{ matrix.triple }} | |
runs-on: ${{ matrix.os }} | |
needs: [test, prepare-packaging-tools] | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- triple: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
rpm: true | |
- triple: aarch64-unknown-linux-gnu | |
os: ubuntu-latest | |
rpm: true | |
- triple: armv7-unknown-linux-gnueabihf | |
os: ubuntu-latest | |
rpm: true | |
- triple: arm-unknown-linux-gnueabihf | |
os: ubuntu-latest | |
# https://github.com/briansmith/ring/issues/1419 | |
# - triple: riscv64gc-unknown-linux-gnu | |
# os: ubuntu-latest | |
- triple: x86_64-apple-darwin | |
os: macos-latest | |
- triple: aarch64-apple-darwin | |
os: macos-latest | |
- triple: x86_64-pc-windows-msvc | |
os: windows-latest | |
# https://github.com/briansmith/ring/issues/1167 | |
# - triple: aarch64-pc-windows-msvc | |
# os: windows-latest | |
steps: | |
- name: Setup Rust | |
shell: bash -eux {0} | |
run: | | |
rustup toolchain install stable --profile minimal --target ${{ matrix.triple }} | |
rustup default stable | |
- name: Get packaging tools from cache | |
if: runner.os == 'Linux' | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-cargo-packaging-tools | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/.crates* | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set artifact name | |
shell: bash | |
run: | | |
version="$(git describe --tags --match "v*.*.*" --always)" | |
echo "version: $version" | |
echo "GIT_TAG_VERSION=$version" >> $GITHUB_ENV | |
name="website-stalker-$version-${{ matrix.triple }}" | |
echo "artifact: $name" | |
echo "ARTIFACT_NAME=$name" >> $GITHUB_ENV | |
- name: Fetch dependencies | |
run: cargo fetch --verbose --locked | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --verbose --locked --all-features --target ${{ matrix.triple }} | |
use-cross: ${{ runner.os == 'Linux' }} | |
- name: Package tar.gz (*nix) | |
if: runner.os != 'Windows' | |
run: > | |
tar -cv | |
CHANGELOG.md LICENSE README.md | |
systemd | |
-C target/ completions/ -C ../ | |
-C target/${{ matrix.triple }}/release/ website-stalker | |
| gzip --best > ${{ env.ARTIFACT_NAME }}.tar.gz | |
- name: Package zip (Windows) | |
if: runner.os == 'Windows' | |
run: > | |
7z a ${{ env.ARTIFACT_NAME }}.zip | |
CHANGELOG.md LICENSE README.md | |
./target/completions/ | |
./target/${{ matrix.triple }}/release/website-stalker.exe | |
- name: Package deb | |
if: runner.os == 'Linux' | |
run: cargo deb --verbose --no-build --no-strip --target ${{ matrix.triple }} --output ${{ env.ARTIFACT_NAME }}.deb | |
- name: Package rpm | |
if: matrix.rpm | |
run: cargo generate-rpm --auto-req no --target ${{ matrix.triple }} --output ${{ env.ARTIFACT_NAME }}.rpm | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.triple }} | |
path: | | |
*.deb | |
*.rpm | |
*.tar.gz | |
*.zip | |
- name: Create GitHub release | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
*.deb | |
*.rpm | |
*.tar.gz | |
*.zip | |
aur-publish: | |
name: AUR ${{ matrix.name }} | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
needs: github-release | |
strategy: | |
fail-fast: false | |
matrix: | |
name: | |
- website-stalker | |
- website-stalker-bin | |
steps: | |
- uses: ATiltedTree/create-aur-release@v1 | |
with: | |
package_name: ${{ matrix.name }} | |
commit_username: GitHub Actions | |
commit_email: [email protected] | |
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }} |