-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (151 loc) · 6.1 KB
/
Copy pathrelease.yml
File metadata and controls
182 lines (151 loc) · 6.1 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
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
name: release
on:
push:
tags:
- "v*"
# schedule:
# # Run every night
# - cron: "0 4 * * *"
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@v3
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 ${{ steps.cliff-args.outputs.args }}
- name: 📝 Set Job Summary
run: |
echo "${{ steps.git-cliff.outputs.content }}" >> $GITHUB_STEP_SUMMARY
build:
name: 🛠 Build and bundle (${{ matrix.config.name }})
runs-on: ${{ matrix.config.os }}
continue-on-error: true
outputs:
release_version: ${{ env.RELEASE_VERSION }}
env:
CARGO_TERM_COLOR: always
strategy:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, target: "x86_64-unknown-linux-gnu", name: "linux-x86_64" }
- { os: ubuntu-latest, target: "aarch64-unknown-linux-gnu", name: "linux-arm64" }
- { os: macos-latest, target: "x86_64-apple-darwin", name: "macos-x86_64" }
- { os: macos-latest, target: "aarch64-apple-darwin", name: "macos-arm64" }
- { os: windows-latest, target: "x86_64-pc-windows-msvc", name: "windows-x86_64" }
steps:
- name: 🧮 Calculate release version name
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
#not needed while using cross
# - name: Install platform specific dependencies [Linux]
# if: matrix.config.os == 'ubuntu-latest'
# run: |
# sudo apt-get update; sudo apt-get install libasound2-dev libudev-dev --no-install-recommends
- name: Cache rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: release-${{ matrix.config.name }}
prefix-key: v0 #increment this to bust the cache if needed
save-if: ${{ github.event_name != 'schedule' }}
- name: Install cargo-bundle [Unix]
if: matrix.config.os != 'windows-latest'
run: cargo install --git https://github.com/burtonageo/cargo-bundle
- name: Install ${{ matrix.config.target }} target
run: rustup target add ${{ matrix.config.target }}
- name: 🛠 Build [windows]
if: matrix.config.os == 'windows-latest'
run: |
cargo build --release --locked --features bundle --target ${{ matrix.config.target }}
- name: 🛠 Build + Bundle [Linux]
if: matrix.config.os == 'ubuntu-latest'
run: |
cargo install cross --locked
cross build --release --target ${{ matrix.config.target }}
CARGO_BUNDLE_SKIP_BUILD=1 cargo bundle --release --features bundle --target ${{ matrix.config.target }}
- name: 🛠 Build + Bundle [Macos]
if: matrix.config.os == 'macos-latest'
run: |
cargo bundle --release --features bundle --target ${{ matrix.config.target }}
- name: Prepare artifacts [Windows]
shell: bash
if: matrix.config.os == 'windows-latest'
run: |
release_dir="galaxy-${{ env.RELEASE_VERSION }}"
artifact_path="galaxy-${{ env.RELEASE_VERSION }}-${{ matrix.config.name }}.zip"
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_ENV
mkdir $release_dir
cp target/${{ matrix.config.target }}/release/galaxy.exe $release_dir/
cp -R assets/ $release_dir/
7z a -tzip $artifact_path $release_dir/
- name: Prepare artifacts [Macos]
shell: bash
if: matrix.config.os == 'macos-latest'
run: |
release_dir="galaxy-${{ env.RELEASE_VERSION }}.app"
artifact_path="galaxy-${{ env.RELEASE_VERSION }}-${{ matrix.config.name }}.tar.gz"
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_ENV
mkdir $release_dir
cp -r 'target/${{ matrix.config.target }}/release/bundle/osx/galaxy.app/' $release_dir/
tar -czvf $artifact_path $release_dir/
- name: Prepare artifacts [Linux (.deb)]
shell: bash
if: matrix.config.os == 'ubuntu-latest'
run: |
artifact_path="galaxy-${{ env.RELEASE_VERSION }}-${{ matrix.config.name }}.deb"
echo "ARTIFACT_PATH=$artifact_path" >> $GITHUB_ENV
cp target/${{ matrix.config.target }}/release/bundle/deb/*.deb $artifact_path
- name: ⏫️ Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_PATH }}
path: ${{ env.ARTIFACT_PATH }}
if-no-files-found: error
publish:
name: 🚀 Publish
needs:
- generate_changelog
- build
runs-on: ubuntu-latest
steps:
- name: ⬇️ Download Artifacts
uses: actions/download-artifact@v3
- name: 🔒 Generate Checksums
run: for file in galaxy-*/galaxy-*; 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.outputs.release_version }}
file: galaxy-*/galaxy-*
file_glob: true
overwrite: true
prerelease: ${{ github.event_name != 'push' }}
body: ${{ needs.generate_changelog.outputs.release_body }}
tag: ${{ needs.build.outputs.release_version }}
repo_token: ${{ secrets.GITHUB_TOKEN }}