Skip to content

v0.3.1

v0.3.1 #198

Workflow file for this run

name: Publish Binary
on:
# This action runs whenever a release is published
release:
types:
- published
# Run on pull requests to publish binaries to pull request workflow runs
pull_request:
branches:
- main
paths:
- bin/**
- examples/**
- src/**
- Cargo.*
- rust-toolchain.toml
- .github/workflows/publish.yaml
permissions:
contents: read # Default token to read
jobs:
upload-artifact:
if: ${{ github.repository_owner == 'edera-dev' && (github.event_name == 'release' || github.event.pull_request.head.repo.full_name == github.repository) }}
name: Publish Binary
permissions:
contents: write # Needed to publish binary
strategy:
fail-fast: false
matrix:
platform:
- { os: linux, arch: x86_64, libc: musl, static: true, on: ubuntu-latest }
- { os: linux, arch: x86_64, libc: gnu, static: true, on: ubuntu-latest }
- { os: linux, arch: x86_64, libc: gnu, static: false, on: ubuntu-latest }
env:
TARGET_OS: '${{ matrix.platform.os }}'
TARGET_ARCH: '${{ matrix.platform.arch }}'
TARGET_LIBC: '${{ matrix.platform.libc }}'
STATIC_BINARY: '${{ matrix.platform.static }}'
runs-on: '${{ matrix.platform.on }}'
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@5d458579430fc14a04a08a1e7d3694f545e91ce6 # zizmor: ignore[stale-action-refs] -- pinned to stable branch
- name: Install cargo-make
run: cargo install cargo-make
- name: 'Build binary'
run: cargo make --profile release build
- name: 'Set platform name'
id: name
run: |
platform="${TARGET_OS}-${TARGET_ARCH}-${TARGET_LIBC}"
# Adding -static to a musl binary name is redundant
[ "${STATIC_BINARY}" = "true" ] && [ "${TARGET_LIBC}" != "musl" ] && platform="${platform}-static"
echo "platform=$platform" >> $GITHUB_OUTPUT
- name: 'Assemble styrolite executable'
run: |
tag_name="${TAG_NAME}"
[ -z $tag_name ] && tag_name="${DEFAULT_BRANCH}"
export STYROLITE_TAG_NAME="${tag_name}"
export STYROLITE_PLATFORM
export STYROLITE_RELEASE_DIR='target/*/release'
cargo make --profile release assemble-release-assets
env:
TAG_NAME: '${{ github.event.release.tag_name }}'
DEFAULT_BRANCH: '${{ github.event.repository.default_branch }}'
STYROLITE_PLATFORM: '${{ steps.name.outputs.platform }}'
- name: 'Upload styrolite to workflow run'
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: styrolite-${{ steps.name.outputs.platform }}
path: |
target/assets/*
- name: generate cultivator token
if: ${{ github.event_name == 'release' }}
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
id: generate-token
with:
app-id: "${{ secrets.EDERA_CULTIVATION_APP_ID }}"
private-key: "${{ secrets.EDERA_CULTIVATION_APP_PRIVATE_KEY }}"
- name: 'Upload all release artifacts'
if: ${{ github.event_name == 'release' }}
run: |
export STYROLITE_TAG_NAME="${TAG_NAME}"
cargo make --profile release upload-release-assets
env:
GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}"
TAG_NAME: '${{ github.event.release.tag_name }}'