Skip to content

Commit 6c9cd6e

Browse files
authored
Merge pull request #332 from Vap0r1ze/chore/release-action
Add workflow for GitHub release builds
2 parents b7b7d0f + 2d18ac3 commit 6c9cd6e

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.github/scripts/get-release-notes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { readFileSync } = require("fs");
2+
let md = readFileSync("changelog.md", "utf-8")
3+
if (md.includes(`## ${process.argv[2]}`)) {
4+
let notes = md
5+
.replaceAll(process.argv[2], "\0VER\0")
6+
.match(/(?<=^|\n)## \0VER\0 .*?(?=\n## |$)/s)[0]
7+
.replaceAll("\0VER\0", process.argv[2])
8+
.trim()
9+
console.log(notes)
10+
}

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '[0-9]+.[0-9]+.[0-9]+'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
# Create the release without assets
13+
create_release:
14+
name: Create release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Ensure tag matches cargo version
19+
run: |
20+
CARGO_PKG_VERSION=$(cargo pkgid | cut -d# -f2)
21+
if [ "${{ github.ref_name }}" != "$CARGO_PKG_VERSION" ]; then
22+
echo "Tag ${{ github.ref_name }} does not match cargo version $CARGO_PKG_VERSION"
23+
exit 1
24+
fi
25+
- name: Prepare release notes
26+
run: node .github/scripts/get-release-notes.js ${{ github.ref_name }} >> release_notes.md
27+
- name: Create release
28+
uses: softprops/action-gh-release@v1
29+
with:
30+
body_path: ./release_notes.md
31+
32+
# Create the binaries and upload them as release assets
33+
create_binaries:
34+
name: Create binary
35+
needs: create_release
36+
runs-on: ${{ matrix.os }}
37+
env:
38+
BINARY_EXT: ${{ matrix.os == 'windows-latest' && '.exe' || '' }}
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
include:
43+
- { os: macos-latest, target: x86_64-apple-darwin }
44+
- { os: macos-latest, target: aarch64-apple-darwin }
45+
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
46+
- { os: windows-latest, target: x86_64-pc-windows-msvc }
47+
- { os: windows-latest, target: aarch64-pc-windows-msvc }
48+
steps:
49+
- uses: actions/checkout@v3
50+
51+
# Install dependencies
52+
- if: matrix.target == 'x86_64-unknown-linux-musl'
53+
run: sudo apt-get install -y musl-tools
54+
- if: matrix.os == 'ubuntu-latest'
55+
run: sudo apt-get install -y libasound2-dev libudev-dev
56+
57+
# Build
58+
- name: Install target
59+
run: rustup target add ${{ matrix.target }}
60+
- name: Build
61+
run: cargo build --bin uiua --features audio --release --target ${{ matrix.target }} --verbose
62+
63+
- name: Zip
64+
run: 7z a -tzip uiua-bin-${{matrix.target}}.zip ./target/${{matrix.target}}/release/uiua${{env.BINARY_EXT}}
65+
66+
- name: Upload release assets
67+
uses: softprops/action-gh-release@v1
68+
with:
69+
files: |
70+
uiua-bin-${{matrix.target}}.zip

0 commit comments

Comments
 (0)