-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (121 loc) · 4.28 KB
/
release.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Release to GitHub and Crates.io
on:
pull_request:
types:
- closed
env:
# Disable incremental build
CARGO_INCREMENTAL: 0
PJ_NAME: tempura
jobs:
version:
name: Get version from git tag
runs-on: ubuntu-latest
if: ${{ startsWith(github.head_ref, 'release/') && github.event.pull_request.merged }}
outputs:
version: ${{ steps.s.outputs.version }}
steps:
- id: s
run: |
ref=${{ github.head_ref }}
version=${ref#release/}
echo $version
echo "version=$version" >> $GITHUB_OUTPUT
build:
name: Build for ${{ matrix.target }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: ${{ startsWith(github.head_ref, 'release/') && github.event.pull_request.merged }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: i686-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: i686-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: i686-pc-windows-msvc
os: windows-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v3
- name: Setup | Rust Toolchain
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Build | Build
uses: actions-rs/cargo@v1.0.1
with:
command: build
args: --release --locked --target=${{ matrix.target }}
use-cross: ${{ matrix.os == 'ubuntu-latest' }}
- name: Post Build | Compress artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../${{ env.PJ_NAME }}-${{ matrix.target }}.tar.gz ${{ env.PJ_NAME }}
cd -
- name: Post Build | Compress artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ env.PJ_NAME }}-${{ matrix.target }}.zip ${{ env.PJ_NAME }}.exe
cd -
- name: Post Build | Upload artifacts [-nix]
uses: actions/upload-artifact@v3
if: matrix.os != 'windows-latest'
with:
name: ${{ env.PJ_NAME }}-${{ matrix.target }}.tar.gz
path: ${{ env.PJ_NAME }}-${{ matrix.target }}.tar.gz
- name: Post Build | Upload artifacts [Windows]
uses: actions/upload-artifact@v3
if: matrix.os == 'windows-latest'
with:
name: ${{ env.PJ_NAME }}-${{ matrix.target }}.zip
path: ${{ env.PJ_NAME }}-${{ matrix.target }}.zip
github_release:
name: Make a new GitHub release for ${{ needs.version.outputs.version }}
needs: [build, version]
runs-on: ubuntu-latest
if: ${{ startsWith(github.head_ref, 'release/') && github.event.pull_request.merged }}
steps:
- name: Download release note
uses: dawidd6/action-download-artifact@v2
with:
workflow: pre-release.yml
workflow_conclusion: success
- name: Download artifacts
uses: actions/download-artifact@v4.1.7
with:
merge-multiple: true
- name: Add Artifacts to Release
uses: softprops/action-gh-release@v1
with:
files: ${{ env.PJ_NAME }}-*/${{ env.PJ_NAME }}-*
body_path: release-note/RELEASE_NOTE.md
tag_name: ${{ needs.version.outputs.version }}
crates_io_publish:
name: Publish ${{ needs.version.outputs.version }} to Crates.io
needs: [build]
runs-on: ubuntu-latest
if: ${{ startsWith(github.head_ref, 'release/') && github.event.pull_request.merged }}
steps:
- name: Setup | Checkout
uses: actions/checkout@v3
- name: Publish
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}