Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub workflows for releasing Vamp-ir binaries #108

Merged
merged 3 commits into from
Jun 16, 2023
Merged
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
34 changes: 34 additions & 0 deletions .github/workflows/clean-up-cache.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: cleanup caches by a branch
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Cleanup
run: |
gh extension install actions/gh-actions-cache

REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"

echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )

## Setting this to not fail the workflow while deleting cache keys.

set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
do
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113 changes: 113 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: release

permissions:
contents: write

on:
workflow_dispatch:
inputs:
draft:
type: boolean
description: "Create a draft release"
required: true
default: false

release-type:
type: choice
default: "release"
options:
- "pre-release"
- "release"
tag:
description: "version to release (e.g. major.minor.patch)"
required: true


concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true

env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10

defaults:
run:
shell: bash

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md # for notable changes
token: ${{ secrets.GITHUB_TOKEN }}
files: |
LICENSE-MIT
LICENSE-APACHE
README.md
tag_name: ${{ github.event.inputs.tag }}
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ github.event.inputs.release-type == 'pre-release' }}
fail_on_unmatched_files: true

upload-assets:
needs: create-release
strategy:
matrix:
include:
# Linux targets
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
# macOS targets
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Rust Cache
uses: Swatinem/[email protected]

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
target: ${{ matrix.target }}
override: true
components: rust-std,rustfmt
# https://rust-lang.github.io/rustup-components-history/

- name: Show rust toolchain info
run: rustup show

- name: Run tests
run: cargo test

# TODO use github.ref tag as the version for the rust bin

- uses: taiki-e/upload-rust-binary-action@v1
if: success()
with:
bin: vamp-ir
target: ${{ matrix.target }}
ref: refs/tags/${{ github.event.inputs.tag }}
asset: LICENSE-APACHE,LICENSE-MIT,README.md
token: ${{ secrets.GITHUB_TOKEN }}
profile: release
107 changes: 107 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: test-build

permissions:
contents: write

on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- ready_for_review

env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
RUSTFLAGS: -D warnings
RUSTUP_MAX_RETRIES: 10

defaults:
run:
shell: bash

jobs:
test-linux:
strategy:
matrix:
include:
- target: aarch64-unknown-linux-musl
arch: aarch64-musl
- target: x86_64-unknown-linux-musl
arch: x86_64-musl
runs-on: ubuntu-latest
container: messense/rust-musl-cross:${{ matrix.arch }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
target: ${{ matrix.target }}
override: true
components: rust-std,rustfmt,clippy
- name: Lint
run: |
cargo fmt --all -- --check
cargo clippy || true
#

# uncomment this once there tests to run
# - name: Run tests
# run: cargo test --verbose

- name: release
if: success()
run: cargo build --release --target=${{ matrix.target }}

test-macos:
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Rust Cache
uses: Swatinem/[email protected]

- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
target: ${{ matrix.target }}
override: true
components: rust-std,rustfmt,clippy

- name: Lint
run: |
cargo fmt --all -- --check
cargo clippy || true

# uncomment this once there tests to run
# - name: Run tests
# run: cargo test --verbose

- name: release
if: success()
run: cargo build --release --target=${{ matrix.target }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# What's changed?

- CI: Add GitHub Actions workflow for building and testing on Linux and macOS.
- CI: Add GitHub Actions workflow for releasing Linux and macOS binaries. To release a new version, use the GitHub Workflow Dispatch feature.
- Format code with `cargo fmt`.
Loading