Skip to content

Commit e12f45f

Browse files
committed
ci(release): update release action to new cross compile github action
1 parent 2b4df9b commit e12f45f

File tree

1 file changed

+101
-106
lines changed

1 file changed

+101
-106
lines changed

.github/workflows/release.yml

+101-106
Original file line numberDiff line numberDiff line change
@@ -33,125 +33,120 @@ jobs:
3333
tag: ${{ steps.changelog.outputs.tag }}
3434
name: ${{ steps.changelog.outputs.tag }}
3535
body: ${{ steps.changelog.outputs.clean_changelog }}
36-
linux:
37-
name: Linux Build
38-
runs-on: ubuntu-latest
39-
needs: changelog
40-
strategy:
41-
matrix:
42-
target: [x86_64-unknown-linux-musl, x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf]
43-
steps:
44-
- name: Checkout Source code
45-
uses: actions/checkout@v4
46-
with:
47-
ref: ${{ needs.changelog.outputs.tag }}
48-
- name: Cache Rust dependencies
49-
uses: actions/cache@v3
50-
with:
51-
path: |
52-
~/.cargo/registry
53-
~/.cargo/git
54-
target
55-
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
56-
- name: Install Rust Toolchain
57-
uses: dtolnay/rust-toolchain@master
58-
with:
59-
toolchain: stable
60-
target: ${{ matrix.target }}
61-
- name: Install Build-Tools
62-
run: sudo apt-get update && sudo apt-get install build-essential gcc-multilib
63-
- name: Build target
64-
uses: actions-rs/cargo@v1
65-
with:
66-
use-cross: true
67-
command: build
68-
args: --release --target ${{ matrix.target }}
69-
- name: Upload Release Asset
70-
uses: actions/upload-release-asset@v1
71-
env:
72-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73-
with:
74-
upload_url: ${{ needs.changelog.outputs.upload_url }}
75-
asset_path: target/${{ matrix.target }}/release/red_oxide
76-
asset_name: red_oxide_${{ runner.OS }}_${{ matrix.target }}
77-
asset_content_type: application/x-elf
7836

79-
windows:
80-
name: Windows Build
81-
runs-on: windows-latest
37+
release-build:
38+
name: Build Commit - ${{ matrix.platform.release_for }}
8239
needs: changelog
8340
strategy:
8441
matrix:
85-
target: [i686-pc-windows-msvc, x86_64-pc-windows-msvc]
86-
steps:
87-
- name: Checkout Source code
88-
uses: actions/checkout@v4
89-
with:
90-
ref: ${{ needs.changelog.outputs.tag }}
91-
- name: Cache Rust dependencies
92-
uses: actions/cache@v3
93-
with:
94-
path: |
95-
~/.cargo/registry
96-
~/.cargo/git
97-
target
98-
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
99-
- name: Install Rust Toolchain
100-
uses: dtolnay/rust-toolchain@master
101-
with:
102-
toolchain: stable
103-
target: ${{ matrix.target }}
104-
- name: Build target
105-
uses: actions-rs/cargo@v1
106-
with:
107-
command: build
108-
args: --release --target ${{ matrix.target }}
109-
- name: Upload Release Asset
110-
uses: actions/upload-release-asset@v1
111-
env:
112-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113-
with:
114-
upload_url: ${{ needs.changelog.outputs.upload_url }}
115-
asset_path: target/${{ matrix.target }}/release/red_oxide.exe
116-
asset_name: red_oxide_${{ runner.OS }}_${{ matrix.target }}.exe
117-
asset_content_type: application/vnd.microsoft.portable-executable
42+
platform:
43+
- release_for: FreeBSD-x86_64
44+
os: ubuntu-20.04
45+
target: x86_64-unknown-freebsd
46+
bin: red_oxide
47+
name: red_oxide-FreeBSD-x86_64
48+
command: build
49+
content-type: application/x-elf
11850

119-
macos:
120-
name: MacOS Build
121-
runs-on: macos-latest
122-
needs: changelog
123-
strategy:
124-
matrix:
125-
target: [x86_64-apple-darwin, aarch64-apple-darwin]
51+
- release_for: Linux-x86_64-gnu
52+
os: ubuntu-20.04
53+
target: x86_64-unknown-linux-gnu
54+
bin: red_oxide
55+
name: red_oxide-Linux-x86_64-gnu
56+
command: build
57+
content-type: application/x-elf
58+
59+
- release_for: Linux-x86_64-musl
60+
os: ubuntu-20.04
61+
target: x86_64-unknown-linux-musl
62+
bin: red_oxide
63+
name: red_oxide-Linux-x86_64-musl
64+
command: build
65+
content-type: application/x-elf
66+
67+
- release_for: Linux-i686
68+
os: ubuntu-20.04
69+
target: i686-unknown-linux-gnu
70+
bin: red_oxide
71+
name: red_oxide-Linux-i686
72+
command: build
73+
content-type: application/x-elf
74+
75+
- release_for: Linux-aarch64
76+
os: ubuntu-20.04
77+
target: aarch64-unknown-linux-gnu
78+
bin: red_oxide
79+
name: red_oxide-Linux-aarch64
80+
command: build
81+
content-type: application/x-elf
82+
83+
- release_for: Linux-armv7
84+
os: ubuntu-20.04
85+
target: armv7-unknown-linux-gnueabihf
86+
bin: red_oxide
87+
name: red_oxide-Linux-armv7
88+
command: build
89+
content-type: application/x-elf
90+
91+
- release_for: Windows-x86_64
92+
os: windows-latest
93+
target: x86_64-pc-windows-msvc
94+
bin: red_oxide.exe
95+
name: red_oxide-Windows-x86_64.exe
96+
command: build
97+
content-type: application/vnd.microsoft.portable-executable
98+
99+
- release_for: Windows-i686
100+
os: windows-latest
101+
target: i686-pc-windows-msvc
102+
bin: red_oxide.exe
103+
name: red_oxide-Windows-i686.exe
104+
command: build
105+
content-type: application/vnd.microsoft.portable-executable
106+
107+
- release_for: macOS-x86_64
108+
os: macOS-latest
109+
target: x86_64-apple-darwin
110+
bin: red_oxide
111+
name: red_oxide-Darwin-x86_64
112+
command: build
113+
content-type: application/x-elf
114+
115+
- release_for: macOS-aarch64
116+
os: macOS-latest
117+
target: aarch64-apple-darwin
118+
bin: red_oxide
119+
name: red_oxide-Darwin-aarch64
120+
command: build
121+
content-type: application/x-elf
122+
123+
runs-on: ${{ matrix.platform.os }}
126124
steps:
127125
- name: Checkout Source code
128126
uses: actions/checkout@v4
129127
with:
130128
ref: ${{ needs.changelog.outputs.tag }}
131-
- name: Cache Rust dependencies
132-
uses: actions/cache@v3
133-
with:
134-
path: |
135-
~/.cargo/registry
136-
~/.cargo/git
137-
target
138-
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
139-
- name: Install Rust Toolchain
140-
uses: dtolnay/rust-toolchain@master
141-
with:
142-
toolchain: stable
143-
target: ${{ matrix.target }}
144-
- name: Build target
145-
uses: actions-rs/cargo@v1
146-
with:
147-
command: build
148-
args: --release --target ${{ matrix.target }}
129+
- name: Install musl-tools on Linux
130+
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
131+
if: contains(matrix.platform.name, 'musl')
132+
- name: Build binary
133+
uses: houseabsolute/actions-rust-cross@v0
134+
with:
135+
command: ${{ matrix.platform.command }}
136+
target: ${{ matrix.platform.target }}
137+
args: "--locked --release"
138+
strip: true
139+
- name: Upload Action Artifact
140+
uses: actions/upload-artifact@v4
141+
with:
142+
name: ${{ matrix.platform.name }}
143+
path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
149144
- name: Upload Release Asset
150145
uses: actions/upload-release-asset@v1
151146
env:
152147
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153148
with:
154149
upload_url: ${{ needs.changelog.outputs.upload_url }}
155-
asset_path: target/${{ matrix.target }}/release/red_oxide
156-
asset_name: red_oxide_${{ runner.OS }}_${{ matrix.target }}
157-
asset_content_type: application/x-elf
150+
asset_path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
151+
asset_name: ${{ matrix.platform.name }}
152+
asset_content_type: ${{ matrix.platform.content-type }}

0 commit comments

Comments
 (0)