Merge pull request #95 from jackschedel/working #119
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: Build and publish desktop app | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
id-token: write | |
concurrency: | |
group: releases | |
cancel-in-progress: true | |
jobs: | |
build: | |
if: "!contains(github.event.head_commit.message, '[skip release]')" | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get version from package.json | |
id: packageJson | |
uses: RadovanPelka/github-action-json@main | |
with: | |
path: 'package.json' | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache yarn dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn | |
- name: Cache release assets | |
uses: actions/cache@v3 | |
with: | |
path: ./release | |
key: ${{ runner.os }}-release-${{github.sha}} | |
restore-keys: | | |
${{ runner.os }}-release- | |
- name: Build | |
run: yarn make | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
VITE_GOOGLE_CLIENT_ID: ${{ secrets.GCLIENT }} | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: release-${{ runner.os }} | |
path: ./release | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Commit substring | |
uses: bhowell2/[email protected] | |
id: committag | |
with: | |
value: ${{ github.sha }} | |
length_from_start: 7 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.sha }}-${{ github.run_id }} | |
release_name: Automated Release for ${{ steps.committag.outputs.substring }} | |
draft: false | |
prerelease: false | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v2 | |
- name: Upload Release Asset - Ubuntu | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./release-Linux/koala-client-${{steps.packageJson.outputs.version}}-linux-x86_64.AppImage | |
asset_name: KoalaClient-${{steps.packageJson.outputs.version}}-linux-x86_64.AppImage | |
asset_content_type: application | |
- name: Upload Release Asset - MacOS | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./release-macOS/koala-client-${{steps.packageJson.outputs.version}}-mac-x64.dmg | |
asset_name: KoalaClient-${{steps.packageJson.outputs.version}}-mac-x64.dmg | |
asset_content_type: application | |
- name: Upload Release Asset - Windows | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./release-Windows/koala-client-${{steps.packageJson.outputs.version}}-win-x64.exe | |
asset_name: KoalaClient-${{steps.packageJson.outputs.version}}-win-x64.exe | |
asset_content_type: application | |
- name: Zip Unpacked Release - Windows | |
run: | | |
cd ./release-Windows | |
7z a win-unpacked.zip win-unpacked/ | |
cd .. | |
- name: Upload Unpacked Release - Windows | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./release-Windows/win-unpacked.zip | |
asset_name: KoalaClient-${{steps.packageJson.outputs.version}}-win-x64-portable.zip | |
asset_content_type: zip | |
- name: Zip Hash Info | |
run: | | |
7z a hash-info.zip ./release-Linux/latest-linux.yml ./release-macOS/latest-mac.yml | |
cp ./release-Windows/latest.yml ./release-Windows/latest-windows.yml | |
7z a hash-info.zip ./release-Windows/latest-windows.yml | |
- name: Upload Hash Info | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./hash-info.zip | |
asset_name: hash-info.zip | |
asset_content_type: zip |