-
Notifications
You must be signed in to change notification settings - Fork 14
152 lines (131 loc) · 4.68 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
142
143
144
145
146
147
148
149
150
151
152
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
permissions: write-all
jobs:
# Creates a release and outputs the url
create-release:
name: create-release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
version: ${{ env.VERSION }}
steps:
- name: Get the release version from the tag
shell: bash
if: env.VERSION == ''
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.VERSION }}"
- name: Create GitHub release
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
script: |
try {
const response = await github.rest.repos.createRelease({
draft: false,
generate_release_notes: true,
name: process.env.VERSION,
owner: context.repo.owner,
prerelease: false,
repo: context.repo.repo,
tag_name: process.env.VERSION,
});
core.exportVariable('RELEASE_ID', response.data.id);
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url);
} catch (error) {
core.setFailed(error.message);
}
build-and-upload:
name: Build and upload
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [linux, macos]
include:
- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-musl
use-cross: true
- build: macos
os: macos-latest
target: x86_64-apple-darwin
use-cross: true
- build: windows-gnu
os: windows-latest
target: x86_64-pc-windows-gnu
use-cross: false
- build: windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc
use-cross: false
- build: windows32-msvc
os: windows-latest
target: i686-pc-windows-msvc
use-cross: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1
with:
target: ${{ matrix.target }}
- name: Install Cross
shell: bash
run: |
if [ "${{ matrix.use-cross }}" = "true" ]; then
cargo install cross
fi
- name: Build
shell: bash
run: |
if [ "${{ matrix.use-cross }}" = "true" ]; then
# Ensure cross is installed above if not included in your toolchain
cross build --verbose --release --target ${{ matrix.target }}
else
cargo build --verbose --release --target ${{ matrix.target }}
fi
- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/prj"
- name: Build archive
shell: bash
run: |
dirname="projectable-${{ needs.create-release.outputs.version }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/prj.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/prj" "$dirname"
fi
mv LICENSE "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Upload archive
uses: actions/upload-release-asset@64e5e85fc528f162d7ba7ce2d15a3bb67efb3d80 # v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
publish-cargo:
name: Publish to Cargo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1
- name: Publish to Cargo
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_API_KEY }}