-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (89 loc) · 3.09 KB
/
release-cli.yml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Release CLI crate
on:
push:
tags:
- v[0-9]+.*
jobs:
build:
name: Build (${{ matrix.job.target }})
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
- { target: x86_64-unknown-linux-gnu , os: ubuntu-22.04 }
- { target: x86_64-pc-windows-msvc , os: windows-2022 }
- { target: aarch64-apple-darwin , os: macos-12 }
- { target: x86_64-apple-darwin , os: macos-12 }
defaults:
run:
working-directory: cli
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set file extension for the compiled binary
if: ${{ matrix.job.os == 'windows-2022' }}
run: echo 'FILE_EXTENSION=.exe' >> "$env:GITHUB_ENV"
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- name: Get version (non-windows)
if: ${{ matrix.job.os != 'windows-2022' }}
run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Get version (windows)
if: ${{ matrix.job.os == 'windows-2022' }}
run: echo "VERSION=$(git describe --tags --abbrev=0)" >> $env:GITHUB_ENV
- name: Build ${{ matrix.job.target }}
run: |
cargo build -r --target ${{ matrix.job.target }} --target-dir target
mv target/${{ matrix.job.target }}/release/qrg${{ env.FILE_EXTENSION }} target/qrg-${{ env.VERSION }}-${{ matrix.job.target }}${{ env.FILE_EXTENSION }}
- uses: actions/upload-artifact@v3
with:
name: artifacts
path: cli/target/qrg-${{ env.VERSION }}-${{ matrix.job.target }}${{ env.FILE_EXTENSION }}
create-release:
name: Create release
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download workflow run artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
path: artifacts
- name: Get tag
run: echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Create GitHub release
uses: taiki-e/create-gh-release-action@v1
with:
changelog: cli/CHANGELOG.md
token: ${{ secrets.GH_RELEASE_TOKEN }}
- name: Upload build artifacts
run: gh release upload ${{ env.TAG }} ./artifacts/*
env:
GH_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
publish_cli:
name: Publish to crates.io
runs-on: ubuntu-22.04
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Use cached dependencies
uses: Swatinem/rust-cache@v2
- name: Prepare
run: cargo install cargo-release
- name: Login to Crates.io
run: cargo login ${{ secrets.CRATESIO_TOKEN }}
- name: Publish CLI
working-directory: ./cli
run: cargo release publish --execute --no-confirm --allow-branch HEAD