-
Notifications
You must be signed in to change notification settings - Fork 83
169 lines (142 loc) · 5.55 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
name: Release
on:
push:
tags:
- "v*.*.*"
env:
MACOSX_DEPLOYMENT_TARGET: 10.7
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
railway_version: ${{ env.CLI_VERSION }}
steps:
- name: Get the release version from the tag
shell: bash
if: env.CLI_VERSION == ''
run: |
# Apparently, this is the right way to get a tag name. Really?
#
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
echo "CLI_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "version is: ${{ env.CLI_VERSION }}"
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Build Changelog
id: build_changelog
uses: mikepenz/[email protected]
with:
configuration: ".github/changelog-configuration.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub release
id: release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.CLI_VERSION }}
name: ${{ env.CLI_VERSION }}
build-release:
name: Build Release Assets
needs: ["create-release"]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: i686-unknown-linux-musl
os: ubuntu-latest
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: arm-unknown-linux-musleabihf
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macOS-latest
- target: aarch64-apple-darwin
os: macOS-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: i686-pc-windows-msvc
os: windows-latest
- target: x86_64-pc-windows-gnu
os: windows-latest
- target: i686-pc-windows-gnu
os: ubuntu-latest
use-cross: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build release binary
uses: actions-rs/cargo@v1
with:
command: build
args: --release --locked --target ${{ matrix.target }}
use-cross: ${{ matrix.use-cross || matrix.os == 'ubuntu-latest' }}
- name: Prepare binaries (zip) [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip railway.exe
7z a ../../../railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}.zip railway.exe
cd -
- name: Prepare binaries (tar) [Windows]
if: matrix.os == 'windows-latest' || matrix.target == 'i686-pc-windows-gnu'
run: |
cd target/${{ matrix.target }}/release
strip railway.exe
7z a -ttar archive.tar railway.exe
7z a -tgzip ../../../railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}.tar.gz archive.tar
cd -
- name: Prepare binaries [-linux]
if: matrix.os != 'windows-latest' && matrix.target != 'i686-pc-windows-gnu'
run: |
cd target/${{ matrix.target }}/release
strip railway || true
tar czvf ../../../railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}.tar.gz railway
cd -
- name: Upload release archive
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create-release.outputs.railway_version }}
files: railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}*
- name: Install musl-tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Install cargo-deb
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo install cargo-deb
- name: Generate .deb package file
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo deb --target x86_64-unknown-linux-musl --output railway-${{ needs.create-release.outputs.railway_version }}-amd64.deb
- name: Upload .deb package file
if: matrix.target == 'x86_64-unknown-linux-musl'
uses: svenstaro/upload-release-action@v2
with:
tag: ${{ needs.create-release.outputs.railway_version }}
file: railway-${{ needs.create-release.outputs.railway_version }}-amd64.deb
- name: Update homebrew tap
uses: mislav/bump-homebrew-formula-action@v2
if: "matrix.target == 'x86_64-apple-darwin' || matrix.target == 'aarch64-apple-darwin' && !contains(github.ref, '-')"
with:
formula-name: rlwy
formula-path: rlwy.rb
homebrew-tap: railwayapp/homebrew-tap
download-url: https://github.com/railwayapp/cli/releases/latest/download/railway-${{ needs.create-release.outputs.railway_version }}-${{ matrix.target }}.tar.gz
env:
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}