Skip to content

Commit b9715b0

Browse files
committed
Implement an automated release pipeline with github actions
1 parent 3f5d347 commit b9715b0

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

.github/workflows/release.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["*.*.*"]
6+
7+
env:
8+
CARGO_TERM_COLOR: always
9+
10+
jobs:
11+
build-and-release:
12+
name: Build and release
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- target: x86_64-unknown-linux-gnu
18+
os: ubuntu-latest
19+
name: gdscript-formatter-linux-x86_64
20+
- target: aarch64-unknown-linux-gnu
21+
os: ubuntu-latest
22+
name: gdscript-formatter-linux-aarch64
23+
- target: x86_64-apple-darwin
24+
os: macos-latest
25+
name: gdscript-formatter-macos-x86_64
26+
- target: aarch64-apple-darwin
27+
os: macos-latest
28+
name: gdscript-formatter-macos-aarch64
29+
- target: x86_64-pc-windows-msvc
30+
os: windows-latest
31+
name: gdscript-formatter-windows-x86_64.exe
32+
- target: aarch64-pc-windows-msvc
33+
os: windows-latest
34+
name: gdscript-formatter-windows-aarch64.exe
35+
36+
runs-on: ${{ matrix.os }}
37+
permissions:
38+
contents: write
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v5
42+
43+
- name: Install Rust
44+
uses: dtolnay/rust-toolchain@stable
45+
with:
46+
targets: ${{ matrix.target }}
47+
48+
# This is a tool that should cache the Rust dependencies and improve build times.
49+
- name: Setup cache
50+
uses: Swatinem/rust-cache@v2
51+
with:
52+
key: ${{ matrix.target }}
53+
54+
# This is a toolchain to build cross-platform binaries with rust. We use
55+
# it for other architectures and OSes than the build runner's.
56+
- name: Install cross
57+
if: matrix.os == 'ubuntu-latest' && matrix.target != 'x86_64-unknown-linux-gnu'
58+
run: cargo install cross --git https://github.com/cross-rs/cross
59+
60+
# Build either with cross or cargo, depending on the target.
61+
- name: Build binary
62+
run: |
63+
if [[ "${{ matrix.os }}" == "ubuntu-latest" && "${{ matrix.target }}" != "x86_64-unknown-linux-gnu" ]]; then
64+
cross build --verbose --locked --release --target ${{ matrix.target }}
65+
else
66+
cargo build --verbose --locked --release --target ${{ matrix.target }}
67+
fi
68+
shell: bash
69+
70+
# This program makes the executable smaller by stripping debug symbols (on macOS and Linux at least).
71+
- name: Strip binary (Linux and macOS)
72+
if: matrix.os != 'windows-latest'
73+
run: strip target/${{ matrix.target }}/release/gdscript-formatter
74+
75+
- name: Move and rename binary
76+
run: |
77+
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
78+
mv target/${{ matrix.target }}/release/gdscript-formatter.exe ${{ matrix.name }}
79+
else
80+
mv target/${{ matrix.target }}/release/gdscript-formatter ${{ matrix.name }}
81+
fi
82+
shell: bash
83+
84+
- name: Compress (Linux and macOS)
85+
if: matrix.os != 'windows-latest'
86+
run: tar -czf ${{ matrix.name }}.tar.gz ${{ matrix.name }}
87+
88+
- name: Compress (Windows)
89+
if: matrix.os == 'windows-latest'
90+
run: 7z a ${{ matrix.name }}.zip ${{ matrix.name }}
91+
92+
- name: Create/Update Release
93+
uses: softprops/action-gh-release@v2
94+
with:
95+
name: GDScript formatter ${{ github.ref_name }}
96+
body: |
97+
A fast code formatter for GDScript in Godot 4.
98+
files: |
99+
*.tar.gz
100+
*.zip
101+
draft: false
102+
prerelease: false
103+
env:
104+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)