-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (82 loc) · 2.64 KB
/
ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: CI
on: [push]
env:
RUST_VERSION: stable
APP_NAME: iroga
jobs:
build:
name: Build and test (${{ matrix.triplet }})
strategy:
matrix:
include:
- os: ubuntu-latest
triplet: x86_64-unknown-linux-gnu
artifact: iroga
- os: windows-latest
triplet: x86_64-pc-windows-msvc
artifact: iroga.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust tools
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.triplet }}
- name: Cache Cargo Rust
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: cargo build --locked --release
- run: cargo test --locked --release
- name: Upload app
uses: actions/upload-artifact@v4
with:
name: ${{ env.APP_NAME }}-${{ matrix.triplet }}
path: ${{ github.workspace }}/target/release/${{ matrix.artifact }}
retention-days: 1
release:
name: Release to Github
needs: build
if: ${{ contains(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./target
- name: Rename artifacts files
run: |
mkdir release-files
mv ./target/*windows*/${{ env.APP_NAME }}.exe ./release-files/${{env.APP_NAME }}-x86_64-pc-windows-msvc.exe
mv ./target/*linux*/${{ env.APP_NAME }} ./release-files/${{ env.APP_NAME }}-x86_64-unknown-linux-gnu
ls -R
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_VERSION=${GITHUB_REF#refs/*/}
gh release create $TAG_VERSION --generate-notes --latest -t "${{ env.APP_NAME }}-$TAG_VERSION" ./release-files/*
publish:
name: Publish to crates.io
needs: build
if: ${{ contains(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust tools
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.triplet }}
- name: Cargo publish
run: cargo publish --token ${CARGO_REGISTRY_TOKEN}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}