Skip to content

Release

Release #118

Workflow file for this run

name: Release
on:
# Runs this workflow when a tag is done to releases branch.
push:
tags:
# Regex for a version number such as 0.2.1
- "v[0-9]+.[0-9]+.[0-9]+"
# Runs this workflow every night at midnight.
schedule:
- cron: 0 0 * * *
# Allows 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:
# Hardcoded on 'schedule'
- if: github.event_name == 'schedule'
run: |
echo "VERSION=nightly" >> $GITHUB_ENV
echo "BRANCH=develop" >> $GITHUB_ENV
# Manual input on 'workflow_dispatch'
- if: github.event_name == 'workflow_dispatch'
run: |
echo "VERSION=${{ github.event.inputs.tagname }}" >> $GITHUB_ENV
echo "BRANCH=develop" >> $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/}" >> $GITHUB_ENV
echo "BRANCH=releases" >> $GITHUB_ENV
- id: output
run: |
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
# Builds the frontend using the reusable action.
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
# Builds multiple version of the backend and package them.
backend:
name: Cross-platform build BACKEND
runs-on: ${{ matrix.os }}
needs:
- prepare
- website
env:
CARGO_TERM_COLOR: always
CROSS_CONFIG: ./backend/Cross.toml
strategy:
matrix:
include:
- name: linux-x86_64
target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cross: true
- name: darwin-x86_64
target: x86_64-apple-darwin
os: macos-latest
cross: false
- name: windows-x86_64
target: x86_64-pc-windows-msvc
os: windows-latest
cross: false
- name: raspberryPi-64bits
target: aarch64-unknown-linux-gnu # raspberryPI OS 64bits
os: ubuntu-latest
cross: true
- name: raspberryPi-32bits
target: armv7-unknown-linux-gnueabihf # raspberryPI OS 32bits
os: ubuntu-latest
cross: true
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.branch }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.target }}
toolchain: stable
override: true
profile: minimal
- name: Update Cross
uses: actions-rs/cargo@v1
with:
command: install
use-cross: false
args: cross --git https://github.com/cross-rs/cross
- name: Compile BACKEND
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.cross }}
command: build
args: --verbose --release --manifest-path "./backend/Cargo.toml" --target ${{ matrix.target }}
- name: Download website
uses: actions/download-artifact@v4
with:
name: website
path: website
merge-multiple: true
- name: Build archive
shell: bash
run: |
binary_name="hermes-studio"
# Build a directory for this version
dirname="$binary_name--${{ matrix.name }}"
mkdir "$dirname"
ls -la
# Move the FRONTEND website into the directory
mv "website" "$dirname"
# Move the release binary (BACKEND) into the directory
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
mv "./backend/target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "./backend/target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
# Compress the directory
if [[ "${{ matrix.target }}" == *"windows"* ]]; 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: ubuntu-latest
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
needs:
- prepare
- backend
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--*
merge-multiple: true
- if: needs.prepare.outputs.version == 'nightly'
run: |
ls -la
echo "SUBJECT=Hermes-Studio nightly build" >> $GITHUB_ENV
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
echo "BODY=Unstable nightly release: built from the latest status of the develop branch." >> $GITHUB_ENV
gh release delete nightly --yes || true
git tag -d nightly || true
git push origin :refs/tags/nightly || true
git tag -f nightly || true
git push --force origin nightly || true
- if: needs.prepare.outputs.version != 'nightly'
run: |
VERSION=${{ needs.prepare.outputs.version }}
echo "SUBJECT=$VERSION" >> $GITHUB_ENV
echo "PRERELEASE=false" >> $GITHUB_ENV
echo "DRAFT=false" >> $GITHUB_ENV
echo "BODY=" >> $GITHUB_ENV
- name: Publish release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.prepare.outputs.version }}
files: hermes-studio--*
generate_release_notes: true
draft: ${{ env.DRAFT }}
name: ${{ env.SUBJECT }}
body: ${{ env.BODY }}
prerelease: ${{ env.PRERELEASE }}
latest: true