-
Notifications
You must be signed in to change notification settings - Fork 175
105 lines (87 loc) · 3.75 KB
/
rust-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
#
# Copyright © 2019-today Peter M. Stahl [email protected]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Rust Release
on:
push:
tags:
- v1.*
jobs:
rust-release:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
name: Linux Binary 64-Bit
target: x86_64-unknown-linux-musl
- os: macos-latest
name: MacOS Binary 64-Bit
target: x86_64-apple-darwin
target2: aarch64-apple-darwin
env:
MACOSX_DEPLOYMENT_TARGET: 10.7
- os: windows-latest
name: Windows Binary 64-Bit
target: x86_64-pc-windows-msvc
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Add rustup default target
run: rustup target add ${{ matrix.target }}
- name: Add rustup Apple ARM64 target
if: ${{ matrix.os == 'macos-latest' }}
run: rustup target add ${{ matrix.target2 }}
- name: Build default target in release mode
run: cargo build --release --target ${{ matrix.target }} --locked
- name: Build Apple ARM64 target in release mode
if: ${{ matrix.os == 'macos-latest' }}
run: cargo build --release --target ${{ matrix.target2 }} --locked
- name: Get latest release version number
id: get_version
uses: battila7/get-version-action@v2
- name: Create zip file on Windows
if: ${{ matrix.os == 'windows-latest' }}
run: |
choco install zip
cd target/${{ matrix.target }}/release
zip grex-${{ steps.get_version.outputs.version }}-${{ matrix.target }}.zip grex.exe
cd ../../..
- name: Create tar.gz file on macOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
chmod +x target/${{ matrix.target }}/release/grex
tar -zcf target/${{ matrix.target }}/release/grex-${{ steps.get_version.outputs.version }}-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release grex
chmod +x target/${{ matrix.target2 }}/release/grex
tar -zcf target/${{ matrix.target2 }}/release/grex-${{ steps.get_version.outputs.version }}-${{ matrix.target2 }}.tar.gz -C target/${{ matrix.target2 }}/release grex
- name: Create tar.gz file on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
chmod +x target/${{ matrix.target }}/release/grex
tar -zcf target/${{ matrix.target }}/release/grex-${{ steps.get_version.outputs.version }}-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release grex
- name: Upload release and assets to GitHub
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
release_name: grex ${{ steps.get_version.outputs.version }}
file_glob: true
file: target/*/release/grex-${{ steps.get_version.outputs.version }}-*.{zip,tar.gz}
- name: Upload release to crates.io
uses: katyo/publish-crates@v2
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}