-
Notifications
You must be signed in to change notification settings - Fork 6
192 lines (161 loc) · 5.35 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
branches:
- 'release-test-[0-9]+.[0-9]+.[0-9]+'
jobs:
# This job is responsible for creating the release _once_ for each tag.
create-release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get release version
run: |
echo "Ref: $GITHUB_REF"
ref_no_tag=${GITHUB_REF#refs/tags/}
echo "No tag: $ref_no_tag"
proxide_version=${ref_no_tag#refs/heads/release-test-}
echo "Final: $proxide_version"
echo "PROXIDE_VERSION=${proxide_version}" >> $GITHUB_ENV
echo "Version: ${proxide_version}"
if [[ $GITHUB_REF == *"release-test"* ]]; then
echo "Release test"
echo "REAL_RELEASE=false" >> $GITHUB_ENV
else
echo "Normal release"
echo "REAL_RELEASE=true" >> $GITHUB_ENV
fi
- name: Version check
run: |
toml_version="$(head Cargo.toml | grep "^version" | sed 's/.*"\(.*\)".*/\1/')"
if [ "$toml_version" != "${{ env.PROXIDE_VERSION }}" ]; then
echo "Version mismatch!"
echo "Tag: ${{ env.PROXIDE_VERSION }}"
echo "Crate: $toml_version"
exit 1
else
echo "TOML and Git versions match"
fi
- name: Create GitHub release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.PROXIDE_VERSION }}
body: |
See the [commit log](https://github.com/Rantanen/proxide/commits/${{ github.sha }}) for recent changes.
- name: Create artifacts
run: |
mkdir artifacts
echo "${{ env.REAL_RELEASE }}" > artifacts/real-release
echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
echo "${{ env.PROXIDE_VERSION }}" > artifacts/release-version
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts
# This job builds each release and uploads the artifacts to the release
# created during the create-release job.
build-release:
name: Build release
needs: ['create-release']
env:
RUST_BACKTRACE: 1
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-2019
steps:
- name: Get release details
uses: actions/download-artifact@v1
with:
name: artifacts
path: artifacts
- name: Read release details
shell: bash
run: |
release_upload_url="$(cat artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
release_version="$(cat artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "Release upload url: $release_upload_url"
echo "Release version: $release_version"
- name: Checkout
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Environment
run: |
cargo --version
rustc --version
- name: Build release
run: |
cargo build --release
- name: Gather artifacts
shell: bash
run: |
target="proxide-${{ env.RELEASE_VERSION }}"
asset_name="proxide-${{ env.RELEASE_VERSION }}"
mkdir -p $target
cp {README.md,LICENSE-MIT,LICENSE-APACHE} $target
if [ "$RUNNER_OS" == "Windows" ]; then
cp target/release/proxide.exe $target
7z a "$asset_name.zip" $target
echo "ASSET=$asset_name.zip" >> $GITHUB_ENV
else
cp target/release/proxide $target
tar czf "$asset_name.tar.gz" $target
echo "ASSET=$asset_name.tar.gz" >> $GITHUB_ENV
fi
- name: Upload release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
publish-release:
name: Publish release
needs: ['build-release']
env:
RUST_BACKTRACE: 1
runs-on: ubuntu-latest
steps:
- name: Get release details
uses: actions/download-artifact@v1
with:
name: artifacts
path: artifacts
- name: Read release details
shell: bash
run: |
real_release="$(cat artifacts/real-release)"
echo "Real release: $real_release"
echo "REAL_RELEASE=$real_release" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Publish to crates.io
if: env.REAL_RELEASE == 'true'
run: |
cargo publish --token "${{ secrets.crates_io }}"