-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #332 from Vap0r1ze/chore/release-action
Add workflow for GitHub release builds
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { readFileSync } = require("fs"); | ||
let md = readFileSync("changelog.md", "utf-8") | ||
if (md.includes(`## ${process.argv[2]}`)) { | ||
let notes = md | ||
.replaceAll(process.argv[2], "\0VER\0") | ||
.match(/(?<=^|\n)## \0VER\0 .*?(?=\n## |$)/s)[0] | ||
.replaceAll("\0VER\0", process.argv[2]) | ||
.trim() | ||
console.log(notes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Create Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
# Create the release without assets | ||
create_release: | ||
name: Create release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Ensure tag matches cargo version | ||
run: | | ||
CARGO_PKG_VERSION=$(cargo pkgid | cut -d# -f2) | ||
if [ "${{ github.ref_name }}" != "$CARGO_PKG_VERSION" ]; then | ||
echo "Tag ${{ github.ref_name }} does not match cargo version $CARGO_PKG_VERSION" | ||
exit 1 | ||
fi | ||
- name: Prepare release notes | ||
run: node .github/scripts/get-release-notes.js ${{ github.ref_name }} >> release_notes.md | ||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
body_path: ./release_notes.md | ||
|
||
# Create the binaries and upload them as release assets | ||
create_binaries: | ||
name: Create binary | ||
needs: create_release | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
BINARY_EXT: ${{ matrix.os == 'windows-latest' && '.exe' || '' }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- { os: macos-latest, target: x86_64-apple-darwin } | ||
- { os: macos-latest, target: aarch64-apple-darwin } | ||
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu } | ||
- { os: windows-latest, target: x86_64-pc-windows-msvc } | ||
- { os: windows-latest, target: aarch64-pc-windows-msvc } | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# Install dependencies | ||
- if: matrix.target == 'x86_64-unknown-linux-musl' | ||
run: sudo apt-get install -y musl-tools | ||
- if: matrix.os == 'ubuntu-latest' | ||
run: sudo apt-get install -y libasound2-dev libudev-dev | ||
|
||
# Build | ||
- name: Install target | ||
run: rustup target add ${{ matrix.target }} | ||
- name: Build | ||
run: cargo build --bin uiua --features audio --release --target ${{ matrix.target }} --verbose | ||
|
||
- name: Zip | ||
run: 7z a -tzip uiua-bin-${{matrix.target}}.zip ./target/${{matrix.target}}/release/uiua${{env.BINARY_EXT}} | ||
|
||
- name: Upload release assets | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
uiua-bin-${{matrix.target}}.zip |