Skip to content

Commit

Permalink
Add release github action.
Browse files Browse the repository at this point in the history
  • Loading branch information
dclause committed Oct 15, 2024
1 parent 537065f commit 955f2fa
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 25 deletions.
27 changes: 27 additions & 0 deletions .github/actions/build_frontend/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'FRONTEND build composite action'
description: 'Builds the frontend'
runs:
using: "composite"
steps:
- name: Setup Node.js
uses: actions/setup-node@v4

- name: Install pnpm
working-directory: ./frontend
run: npm install --global pnpm

- name: Cache .pnpm-store
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
working-directory: ./frontend
run: pnpm install

- name: Run FRONTEND pnpm build
working-directory: ./frontend
run: pnpm build
1 change: 0 additions & 1 deletion .github/workflows/build_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
run: |
sudo apt update
sudo apt install -y pkg-config libudev-dev libasound2-dev
if: contains(matrix.os, 'ubuntu')
- name: Run BACKEND cargo build
working-directory: ./backend
Expand Down
24 changes: 2 additions & 22 deletions .github/workflows/build_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ env:

jobs:
build:

name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -20,26 +19,7 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4

- name: Install pnpm
working-directory: ./frontend
run: npm install --global pnpm

- name: Cache .pnpm-store
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
working-directory: ./frontend
run: pnpm install
ref: 'develop'

- name: Run FRONTEND pnpm build
working-directory: ./frontend
run: pnpm build
- uses: ./github/actions/build_frontend
1 change: 0 additions & 1 deletion .github/workflows/coverage_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
run: |
sudo apt update
sudo apt install -y pkg-config libudev-dev libasound2-dev
if: contains(matrix.os, 'ubuntu')
- name: Generate code coverage
working-directory: ./backend
Expand Down
190 changes: 190 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: Release

on:
push:
branches: [ "releases" ]
tags:
# Regex for a version number such as 0.2.1
- "[0-9]+.[0-9]+.[0-9]+"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
tagname:
description: "Tag name for release"
required: false
default: nightly

jobs:

# Build the tagname and branch
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.output.outputs.version }}
branch: ${{ steps.output.outputs.branch }}
steps:
# Manual input on 'workflow_dispatch'
- if: github.event_name == 'workflow_dispatch'
run: |
{
echo 'VERSION=${{ github.event.inputs.tagname }}'
echo 'BRANCH=develop'
} | tee -a $GITHUB_ENV
# Based on tag name when pushed on 'releases' branch.
- if: github.event_name == 'push'
run: |
TAGNAME=${{ github.ref }}
{
echo 'VERSION=${TAGNAME#refs/tags/}'
echo 'BRANCH=releases'
} | tee -a $GITHUB_ENV
- id: output
run: |
{
echo 'version=$VERSION'
echo 'branch=$BRANCH'
} | tee -a $GITHUB_OUTPUT
website:
name: Build FRONTEND
runs-on: windows-latest
needs: prepare
steps:

- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.branch }}

- uses: ./github/actions/build_frontend

- name: Upload Frontend
uses: actions/upload-artifact@v4
with:
name: website
path: ./frontend/dist/
retention-days: 1

backend:
name: Cross-platform build BACKEND
runs-on: windows-latest
needs:
- prepare
- website
env:
CARGO_TERM_COLOR: always
CROSS_CONFIG: ./backend/Cross.toml

strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
- target: x86_64-apple-darwin
- target: x86_64-pc-windows-gnu
- target: aarch64-unknown-linux-gnu
- target: armv7-unknown-linux-gnueabihf

steps:
- name: Clone repository
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.branch }}

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}

- name: Compile BACKEND
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --verbose --release --manifest-path "./backend/Cargo.toml" --target ${{ matrix.target }}

- name: Download website
uses: actions/download-artifact@v4
with:
name: website

- name: Build archive
shell: bash
run: |
binary_name="hermes-studio"
# Build a directory for this version
dirname="$binary_name-${{ needs.prepare.outputs.version }}-${{ matrix.target }}"
mkdir "$dirname"
# Move the FRONTEND website into the directory
mv "website/" "$dirname"
# Move the release binary (BACKEND) into the directory
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
# Compress the directory
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Upload the archive
uses: actions/upload-artifact@v4
with:
name: ${{ env.ASSET }}
path: ${{ env.ASSET }}
retention-days: 1


publish:
name: Publish release
runs-on: windows-latest
needs:
- prepare
- backend
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write

steps:
# Must perform checkout first, since it deletes the target directory
# before running, and would therefore delete the downloaded artifacts
- uses: actions/checkout@v4

- name: Retrieve all artifacts
uses: actions/download-artifact@v4
with:
pattern: hermes-studio-*

- if: needs.prepare.outputs.version == 'nightly'
run: |
{
echo 'SUBJECT=Hermes-Studio development build'
echo 'PRERELEASE=--prerelease'
} | tee -a $GITHUB_ENV
gh release delete nightly --yes || true
git push origin :nightly || true
- if: needs.prepare.outputs.version != 'nightly'
run: |
{
echo 'SUBJECT=Hermes-Studio release build'
echo 'PRERELEASE='
} | tee -a $GITHUB_ENV
- name: Publish release
uses: softprops/action-gh-release@v2
with:
files: hermes-studio-*
1 change: 0 additions & 1 deletion .github/workflows/test_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
run: |
sudo apt update
sudo apt install -y pkg-config libudev-dev libasound2-dev
if: contains(matrix.os, 'ubuntu')
- name: Run BACKEND all tests
working-directory: ./backend
Expand Down
23 changes: 23 additions & 0 deletions backend/Cross.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
[build]
pre-build = [
"apt-get update && apt-get install --assume-yes ",
"apt-get update && apt-get install -y pkg-config libudev-dev libasound2-dev",
]

# Mac OS
[target.x86_64-apple-darwin]
pre-build = []

# Win OS
[target.x86_64-pc-windows-gnu]
pre-build = []

# raspberryPI OS 64bits
[target.aarch64-unknown-linux-gnu]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes ",
"apt-get update && apt-get install -y pkg-config libudev-dev:$CROSS_DEB_ARCH libasound2-dev:$CROSS_DEB_ARCH",
]

# raspberryPI OS 32bits
[target.armv7-unknown-linux-gnueabihf]
pre-build = [
"dpkg --add-architecture $CROSS_DEB_ARCH",
"apt-get update && apt-get install --assume-yes ",
Expand Down

0 comments on commit 955f2fa

Please sign in to comment.