Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Build assets for projects

on:
push

jobs:
check:
runs-on: ubuntu-latest

strategy:
matrix:
library: [spectra]

defaults:
run:
working-directory: ${{ matrix.library }}
shell: bash

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: Run check
run: cargo check

# test setup
- uses: oven-sh/setup-bun@v2
- name: Run setup
run: cargo build --example example_stdin_stdout_program
# end test setup

- name: Run test
run: cargo test

publish-assets:
permissions: write-all
needs: check

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
binary: [spectra]
include:
- os: windows-latest
platform-name: x86_64-pc-windows
executable-extension: ".exe"
- os: ubuntu-latest
platform-name: x86_64-unknown-linux

runs-on: ${{ matrix.os }}

env:
PROFILE: dev
OUT: target/debug
GH_RELEASE: assets

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: Set variables
id: information
shell: bash
run: |
echo "GITHUB_RUN_DATE=$(TZ="Europe/London" date +"%Y-%m-%d %T")" >> "$GITHUB_OUTPUT"
echo "GIT_LAST_COMMIT=$(git log -n 1 --format="%H")" >> "$GITHUB_OUTPUT"

IFS='~' read -r binary example <<< '${{ matrix.binary }}'
echo "WORKING_DIRECTORY=$binary" >> "$GITHUB_OUTPUT"
if [ -n "$example" ]; then
echo "BUILD_SPECIFIER=--example $example" >> "$GITHUB_OUTPUT"
echo "ASSET_PATH=${{ env.OUT }}/examples/$example" >> "$GITHUB_OUTPUT"
echo "ASSET_NAME=$example" >> "$GITHUB_OUTPUT"
else
echo "BUILD_SPECIFIER=" >> "$GITHUB_OUTPUT"
echo "ASSET_PATH=${{ env.OUT }}/$binary" >> "$GITHUB_OUTPUT"
echo "ASSET_NAME=$binary" >> "$GITHUB_OUTPUT"
fi

- name: Build binary
working-directory: ${{ steps.information.outputs.WORKING_DIRECTORY }}
run: cargo build ${{ steps.information.outputs.BUILD_SPECIFIER }} --profile ${{ env.PROFILE }}
env:
GITHUB_RUN_DATE: ${{ steps.information.outputs.GITHUB_RUN_DATE }}
GIT_LAST_COMMIT: ${{ steps.information.outputs.GIT_LAST_COMMIT }}

- name: Publish binary
working-directory: ${{ steps.information.outputs.WORKING_DIRECTORY }}
shell: bash
env: { "GH_TOKEN": "${{ secrets.GITHUB_TOKEN }}" }
run: |
FROM="${{ steps.information.outputs.ASSET_PATH }}${{ matrix.executable-extension }}"
TO="${{ matrix.binary }}-${{ matrix.platform-name }}${{ matrix.executable-extension }}"
gh release upload $GH_RELEASE "$FROM#$TO" --clobber
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
Loading
Loading