Improve release pipeline #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: [ "v*.*.*"] | ||
env: | ||
CARGO_TERM_COLOR: always | ||
jobs: | ||
build-frontend: | ||
name: Build frontend | ||
runs-on: ubuntu-24.04 | ||
defaults: | ||
run: | ||
working-directory: ./frontend | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
cache: 'npm' | ||
cache-dependency-path: frontend/package-lock.json | ||
- run: npm ci | ||
- run: npm run build | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: frontend | ||
path: frontend/dist | ||
build-amd64: | ||
name: Build AMD64 binary | ||
needs: build-frontend | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: frontend | ||
path: frontend/dist | ||
- run: rustup install 1.84 | ||
- run: rustup default 1.84 | ||
- run: cargo build --release | ||
- run: mv target/armv7-unknown-linux-musleabihf/release/thermagate thermagate-armv7 | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: thermagate-amd64 | ||
path: thermagate-amd64 | ||
build-armv7: | ||
name: Build ARMv7 binary | ||
needs: build-frontend | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: frontend | ||
path: frontend/dist | ||
- run: rustup install 1.84 | ||
- run: rustup default 1.84 | ||
- run: cargo install cross | ||
- run: cross build --release --target armv7-unknown-linux-musleabihf | ||
- run: mv target/armv7-unknown-linux-musleabihf/release/thermagate thermagate-armv7 | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: thermagate-armv7 | ||
path: thermagate-armv7 | ||
release: | ||
name: "Create release" | ||
needs: | ||
- build-amd64 | ||
- build-armv7 | ||
runs-on: "ubuntu-24.04" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
sparse-checkout: | | ||
README.md | ||
CHANGELOG.md | ||
COPYING | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
pattern: thermagate-* | ||
merge-multiple: true | ||
- run: tree | ||
- run: echo tag_name=${{ github.ref == 'refs/heads/main' && 'latest' || github.ref_name }} | ||
- run: echo prerelease=${{ github.ref == 'refs/heads/main' }} | ||
- name: Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
tag_name: ${{ github.ref == 'refs/heads/main' && 'latest' || github.ref_name }} | ||
prerelease: ${{ github.ref == 'refs/heads/main' }} | ||
files: * | ||