-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (114 loc) · 3.94 KB
/
Copy pathdraft-release-rust.yml
File metadata and controls
127 lines (114 loc) · 3.94 KB
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
name: draft release / rust
on:
workflow_call:
inputs:
package:
description: Cargo package
required: true
type: string
permissions:
contents: write
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
jobs:
create_draft_release:
name: create draft release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.gh_release.outputs.upload_url }}
url: ${{ steps.gh_release.outputs.url }}
steps:
- name: Checkout source code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- id: gh_release
name: Create a new GitHub draft release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b
with:
draft: true
generate_release_notes: true
- name: Annotate workflow run with draft release URL
env:
INPUTS_PACKAGE: ${{ inputs.package }}
STEPS_GH_RELEASE_OUTPUTS_URL: ${{ steps.gh_release.outputs.url }}
run: 'echo "### :shipit: Opened draft release for: [${INPUTS_PACKAGE} ${GITHUB_REF_NAME}](${STEPS_GH_RELEASE_OUTPUTS_URL})" >> "$GITHUB_STEP_SUMMARY"'
upload_release_assets:
name: upload release assets
needs:
- create_draft_release
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
build_tool: cargo
- target: aarch64-pc-windows-msvc
os: windows-latest
build_tool: cargo
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
build_tool: cross
- target: x86_64-apple-darwin
os: macos-latest
build_tool: cargo
- target: x86_64-pc-windows-msvc
os: windows-latest
build_tool: cargo
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
build_tool: cargo
runs-on: ${{ matrix.os }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout source code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
persist-credentials: false
- name: Install musl tools
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y musl-tools
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Cache dependencies
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5
with:
shared-key: stable-ubuntu-latest
timeout-minutes: 5
- name: Install cross
if: matrix.os == 'ubuntu-latest'
uses: taiki-e/install-action@7e574ed8bb89811282a11aecb3fe1d043bf5bf0e
with:
tool: cross
- name: Building release assets
run: |
if [[ "${{ matrix.build_tool }}" == "cross" ]]; then
cargo xtask dist --target "${{ matrix.target }}" --cross
else
cargo xtask dist --target "${{ matrix.target }}"
fi
- name: Uploading release assets
env:
INPUTS_PACKAGE: ${{ inputs.package }}
NEEDS_CREATE_DRAFT_RELEASE_OUTPUTS_UPLOAD_URL: ${{ needs.create_draft_release.outputs.upload_url }}
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
extension="zip"
else
extension="tar.gz"
fi
filename="${INPUTS_PACKAGE}-${GITHUB_REF_NAME:1}-${{ matrix.target }}.${extension}"
echo "Uploading ${filename} to: ${NEEDS_CREATE_DRAFT_RELEASE_OUTPUTS_UPLOAD_URL}"
gh release upload "$GITHUB_REF_NAME" "target/dist/${filename}"
echo ":arrow_up: Uploaded release asset ${filename}" >>"$GITHUB_STEP_SUMMARY"