-
Notifications
You must be signed in to change notification settings - Fork 123
144 lines (126 loc) · 4.52 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
name: 🚀 Release
on:
workflow_dispatch:
push:
tags:
- "v*"
defaults:
run:
shell: bash
jobs:
generate_changelog:
name: 📜 Generate Changelog
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: ⬇️ Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: 📠 Calculate Git Cliff Args
id: cliff-args
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "args=--latest" >> $GITHUB_OUTPUT
else
echo "args=--unreleased" >> $GITHUB_OUTPUT
fi
- name: 📜 Generate Changelog
uses: orhun/git-cliff-action@v2
id: git-cliff
with:
args: -vv --strip all ${{ steps.cliff-args.outputs.args }}
- name: 📝 Set Job Summary
run: |
echo "${{ steps.git-cliff.outputs.content }}" >> $GITHUB_STEP_SUMMARY
build_release:
name: 🔨 Build
runs-on: ${{ matrix.config.os }}
continue-on-error: true
outputs:
release_version: ${{ env.RELEASE_VERSION }}
strategy:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, target: "x86_64-unknown-linux-gnu" }
- { os: ubuntu-latest, target: "aarch64-unknown-linux-gnu" }
- { os: macos-latest, target: "x86_64-apple-darwin" }
- { os: macos-latest, target: "aarch64-apple-darwin" }
- { os: windows-latest, target: "x86_64-pc-windows-msvc" }
steps:
- name: 📠 Calculate Release Version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" -o "${{ github.event_name }}" = "schedule" ]; then
echo "RELEASE_VERSION=nightly-$(date '+%Y-%m-%d')" >> $GITHUB_ENV
else
echo "RELEASE_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: ⬇️ Checkout
uses: actions/checkout@v3
- name: 🦀 Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
target: ${{ matrix.config.target }}
- name: 🔨 Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target ${{ matrix.config.target }}
use-cross: true
- name: ⚙️ Prepare artifacts [Windows]
shell: bash
if: matrix.config.os == 'windows-latest'
run: |
release_dir="jumpy-${{ env.RELEASE_VERSION }}"
artifact_path="jumpy-${{ env.RELEASE_VERSION }}-${{ matrix.config.target }}.zip"
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_ENV
mkdir $release_dir
cp target/${{ matrix.config.target }}/release/jumpy.exe $release_dir/
cp -R assets/ $release_dir/
cp LICENSE $release_dir/
7z a -tzip $artifact_path $release_dir/
- name: ⚙️ Prepare artifacts [Unix]
shell: bash
if: matrix.config.os != 'windows-latest'
run: |
release_dir="jumpy-${{ env.RELEASE_VERSION }}"
artifact_path="jumpy-${{ env.RELEASE_VERSION }}-${{ matrix.config.target }}.tar.gz"
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_ENV
mkdir $release_dir
cp target/${{ matrix.config.target }}/release/jumpy $release_dir/
cp -R assets $release_dir
cp LICENSE $release_dir
tar -czvf $artifact_path $release_dir/
- name: ⏫️ Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.ARTIFACT_PATH }}
path: ${{ env.ARTIFACT_PATH }}
if-no-files-found: error
publish_release:
name: 🚀 Publish
needs:
- generate_changelog
- build_release
runs-on: ubuntu-latest
steps:
- name: ⬇️ Download Artifacts
uses: actions/download-artifact@v2
- name: 🔒 Generate Checksums
run: for file in jumpy-*/jumpy-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
- name: 🚀 Publish Release
uses: svenstaro/upload-release-action@v2
with:
release_name: ${{ needs.build_release.outputs.release_version }}
file: jumpy-*/jumpy-*
file_glob: true
overwrite: true
prerelease: ${{ github.event_name != 'push' }}
body: ${{ needs.generate_changelog.outputs.release_body }}
tag: ${{ needs.build_release.outputs.release_version }}
repo_token: ${{ secrets.GITHUB_TOKEN }}