build: Don't drop dirty file for cache hashing in workspace #187
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: Rust | |
on: | |
- push | |
- pull_request | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Generate Cargo.toml.cache (Ignore version=) | |
run: | | |
sed '/^version = /d' Cargo.toml > /tmp/Cargo.toml.cache | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
~/.cargo/git | |
target | |
key: musl-cargo-${{ hashFiles('/tmp/Cargo.toml.cache') }} | |
- name: Run fileserver | |
run: | | |
fixtures/start_fileserver.sh & | |
- name: Remove files for a build with correct version info | |
run: | | |
find target/ -name 'shadow*' -exec rm -r {} + || true | |
find target/ -name 'tsumugu' -delete || true | |
- name: Test & Compile | |
run: | | |
mkdir -p ~/.cargo/{git,registry} | |
# Fix git permission issue with Docker and shadow-rs | |
sudo chown -R root . | |
docker run --rm -t \ | |
--mount type=bind,source=${{ github.workspace }},target=/volume \ | |
--mount type=bind,source=$HOME/.cargo/registry,target=/root/.cargo/registry \ | |
--mount type=bind,source=$HOME/.cargo/git,target=/root/.cargo/git \ | |
--network=host \ | |
clux/muslrust:stable \ | |
cargo test | |
docker run --rm -t \ | |
--mount type=bind,source=${{ github.workspace }},target=/volume \ | |
--mount type=bind,source=$HOME/.cargo/registry,target=/root/.cargo/registry \ | |
--mount type=bind,source=$HOME/.cargo/git,target=/root/.cargo/git \ | |
--network=host \ | |
clux/muslrust:stable \ | |
cargo build --release | |
sudo chown -R runner ~/.cargo/ | |
sudo chown -R runner . | |
# show version info | |
RUST_LOG=debug target/x86_64-unknown-linux-musl/release/tsumugu --version | |
- name: Deploy - Create and Upload Release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: target/x86_64-unknown-linux-musl/release/tsumugu | |
- name: Release to crates.io | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: katyo/publish-crates@v2 | |
with: | |
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} |