CI #1730
Workflow file for this run
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: CI | |
on: | |
pull_request: | |
push: | |
schedule: | |
- cron: '0 0 * * *' # Run every day at 00:00 UTC. | |
env: | |
RUST_BACKTRACE: full # Shows more info when a test fails. | |
BINARY_NAME: tindercrypt | |
jobs: | |
basic_checks: | |
name: Basic checks (cargo ${{ matrix.cmd }}) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
cmd: | |
- fmt | |
- doc | |
include: | |
- cmd: fmt | |
args: --all -- --check | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: rustfmt | |
- name: cargo ${{ matrix.cmd }} | |
run: cargo ${{ matrix.cmd }} ${{ matrix.args }} | |
lint_proto: | |
name: Lint .proto files | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download Uber's prototool | |
run: | | |
wget -O prototool \ | |
https://github.com/uber/prototool/releases/download/v1.9.0/prototool-Linux-x86_64 | |
chmod +x prototool | |
- name: Lint | |
run: ./prototool lint proto | |
test: | |
name: Test ${{ matrix.rust }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
rust: | |
- stable | |
- beta | |
- nightly | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macOS-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Rust (${{ matrix.rust }}) | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
# Catch any breaking changes in the dependencies early, by always updating | |
# them before running the tests. | |
- name: Update dependencies | |
run: cargo update | |
- name: Test | |
run: cargo test -- --nocapture # Allow printing the output of tests | |
build: | |
name: Build on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macOS-latest | |
include: | |
- os: ubuntu-latest | |
arch: linux_amd64 | |
- os: windows-latest | |
arch: windows_amd64 | |
extension: .exe | |
- os: macOS-latest | |
arch: darwin_amd64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Build | |
run: cargo build --release | |
- name: Upload binaries | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.BINARY_NAME }}_${{ matrix.arch }}${{ matrix.extension}} | |
path: "target/release/${{ env.BINARY_NAME }}${{ matrix.extension }}" | |
create_release: | |
name: Create a release | |
runs-on: ubuntu-latest | |
needs: ["basic_checks", "test", "build", "lint_proto"] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Set release tag | |
run: echo GITHUB_RELEASE_TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV | |
- 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 ${{ env.GITHUB_RELEASE_TAG }} | |
draft: true | |
prerelease: false | |
body: | | |
This release contains the latest assets for tag `${{ env.GITHUB_RELEASE_TAG }}`. | |
## Changes | |
The changes for this release can be found in the [changelog]. | |
[changelog]: https://github.com/${{ github.repository }}/blob/${{ env.GITHUB_RELEASE_TAG }}/CHANGELOG.md | |
- name: Store release context | |
run: | | |
cat <<EOF > release_context | |
::set-output name=ref::${{ env.GITHUB_RELEASE_TAG }} | |
::set-output name=upload_url::${{ steps.create_release.outputs.upload_url }} | |
EOF | |
- name: Upload release context | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release_context | |
path: release_context | |
upload_assets: | |
name: Upload release assets (${{ matrix.arch }}) | |
needs: create_release | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: | |
- linux_amd64 | |
- windows_amd64 | |
- darwin_amd64 | |
include: | |
- arch: windows_amd64 | |
extension: .exe | |
steps: | |
- name: Download release context | |
uses: actions/download-artifact@v4 | |
with: | |
name: release_context | |
path: ctx | |
- name: Restore release context | |
id: release_ctx | |
run: cat ctx/release_context | |
- name: Download binary | |
uses: actions/download-artifact@v1 | |
with: | |
name: ${{ env.BINARY_NAME }}_${{ matrix.arch }}${{ matrix.extension}} | |
path: assets_${{ matrix.arch }} | |
- name: Upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.release_ctx.outputs.upload_url }} | |
asset_path: assets_${{ matrix.arch }}/${{ env.BINARY_NAME }}${{ matrix.extension }} | |
asset_name: ${{ env.BINARY_NAME }}_${{ steps.release_ctx.outputs.ref }}_${{ matrix.arch }}${{ matrix.extension}} | |
asset_content_type: application/octet-stream |