-
Notifications
You must be signed in to change notification settings - Fork 117
141 lines (129 loc) · 4.27 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
140
141
name: Release
on:
push:
branches:
- ignore
# - master
tags: [ 'v*' ]
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Build ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-musl
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- i686-pc-windows-msvc
- aarch64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: rnacos-x86_64-unknown-linux-musl.tar.gz
- target: x86_64-apple-darwin
os: macos-latest
name: rnacos-x86_64-apple-darwin.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
name: rnacos-x86_64-pc-windows-msvc.zip
- target: i686-pc-windows-msvc
os: windows-latest
name: rnacos-i686-pc-windows-msvc.zip
- target: aarch64-pc-windows-msvc
os: windows-latest
name: rnacos-aarch64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
# Largely inspired by https://github.com/starship/starship/blob/35a0a20f5c4fea6a08e1b91ff631b089eef8fc50/.github/workflows/deploy.yml
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y musl-tools
# Install gnu-tar because BSD tar is buggy
# https://github.com/actions/cache/issues/403
- name: Install GNU tar (macOS)
if: matrix.os == 'macos-latest'
run: |
brew install gnu-tar
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
- name: Build
if: matrix.target != 'x86_64-unknown-linux-musl'
run: cargo build --release
- name: Build linux-musl
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
cargo build --release --target ${{ matrix.target }}
- name: Archive binary (windows)
if: matrix.os == 'windows-latest'
run: |
cd target/release
7z a ../../${{ matrix.name }} ${{ github.event.repository.name }}.exe
cd -
- name: Archive binary (linux and macOS)
if: ${{ matrix.os != 'windows-latest' && matrix.target !='x86_64-unknown-linux-musl' }}
run: |
cd target/release
tar czvf ../../${{ matrix.name }} ${{ github.event.repository.name }}
cd -
- name: Archive binary (linux-musl)
if: matrix.target =='x86_64-unknown-linux-musl'
run: |
cd target/x86_64-unknown-linux-musl/release
tar czvf ../../../${{ matrix.name }} ${{ github.event.repository.name }}
cd -
- name: Upload binary artifacts
uses: actions/upload-artifact@v3
with:
name: binaries
path: |
*.tar.gz
*.zip
release-crates-io:
name: Release crates.io
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ build ]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- name: cargo login
run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: cargo publish
run: cargo publish
release-github:
permissions:
# Used to sign the release's artifacts with sigstore-python.
id-token: write
# Used to upload release artifacts.
contents: write
name: Publish to GitHub releases
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [ build ]
steps:
- uses: actions/download-artifact@v3
with:
name: binaries
# 暂时移除签名(生成的文件比较多)
#- name: Sigstore Sign
# uses: sigstore/gh-action-sigstore-python@v1.2.3
# with:
# inputs: ./*.tar.gz ./*.zip
# upload-signing-artifacts: true
- name: Release
uses: softprops/action-gh-release@v1
with:
files: |
*.tar.gz
*.zip
# *.sig
# *.crt
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
generate_release_notes: true