Skip to content

Commit 2df7ad9

Browse files
committed
Add release job
1 parent 4be6806 commit 2df7ad9

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/release.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# References:
2+
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/
3+
# https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml
4+
5+
name: release
6+
7+
on:
8+
push:
9+
tags:
10+
- "v[0-9]+.*"
11+
12+
jobs:
13+
create-release:
14+
name: Create release
15+
runs-on: ubuntu-latest
16+
outputs:
17+
upload_url: ${{ steps.create-release.outputs.upload_url }}
18+
steps:
19+
- name: Create release
20+
id: create-release
21+
uses: actions/create-release@v1
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
with:
25+
tag_name: ${{ github.ref }}
26+
release_name: Release ${{ github.ref }}
27+
draft: false
28+
prerelease: false
29+
30+
build-release:
31+
name: build-release
32+
needs: ['create-release']
33+
runs-on: ${{ matrix.os }}
34+
strategy:
35+
matrix:
36+
build: [linux, macos]
37+
include:
38+
- build: linux
39+
os: ubuntu-latest
40+
target: x86_64-unknown-linux-musl
41+
- build: macos
42+
os: macos-latest
43+
target: x86_64-apple-darwin
44+
45+
steps:
46+
- name: Checkout repository
47+
uses: actions/checkout@v2
48+
with:
49+
fetch-depth: 1
50+
51+
- name: Install Rust
52+
uses: actions-rs/toolchain@v1
53+
with:
54+
toolchain: stable
55+
target: ${{ matrix.target }}
56+
profile: minimal
57+
override: true
58+
59+
- name: Build binary
60+
run: cargo build --verbose --release --target=${{ matrix.target }}
61+
62+
- name: Strip binary
63+
run: strip "target/${{ matrix.target }}/release/json-struct"
64+
65+
- name: Create tarball
66+
run: tar zcf "json-struct.tar.gz" -C "target/${{ matrix.target }}/release" json-struct
67+
68+
- name: Upload release archive
69+
uses: actions/upload-release-asset@v1.0.1
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
with:
73+
upload_url: ${{ needs.create-release.outputs.upload_url }}
74+
asset_name: json-struct-${{ matrix.build }}.tar.gz
75+
asset_path: ./json-struct.tar.gz
76+
asset_content_type: application/gzip
77+

0 commit comments

Comments
 (0)