Skip to content

Release app

Release app #25

Workflow file for this run

name: Release build
on:
workflow_dispatch:
inputs:
releaseTag:
description: 'Tag name for the release'
required: true
default: 'v0.6.0'
env:
FORCE_COLOR: true
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 # Install pnpm using packageManager key in package.json
with:
version: latest
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: "pnpm"
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node dependencies
run: pnpm install -g cargo-cp-artifact && pnpm install
- name: Install Electron-Builder
run: pnpm install -g electron-builder
- name: Build
run: npm run packageLinux
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List all files in the dist directory
run: ls -l dist
- name: Delete unpacked builds
run: rm -rf dist/linux-unpacked && rm -rf dist/linux-arm64-unpacked && rm -rf dist/linux-armv7l-unpacked
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: GoofCordLinux
path: dist/
build-windows:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2 # Install pnpm using packageManager key in package.json
with:
version: latest
- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: "pnpm"
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node dependencies
run: pnpm install -g cargo-cp-artifact && pnpm install
- name: Install Electron-Builder
run: pnpm install -g electron-builder
- name: Build
run: npm run packageWindows
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete unpacked builds
run: Remove-Item -LiteralPath ".\dist\win-unpacked" -Force -Recurse
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: GoofCordWindows
path: dist/
release:
runs-on: ubuntu-latest
needs: [build-linux, build-windows]
steps:
- uses: actions/download-artifact@v3
with:
name: GoofCordWindows
path: windows
- uses: actions/download-artifact@v3
with:
name: GoofCordLinux
path: linux
- name: ls
run: ls
- name: Delete unwanted directories
run: rm -rf {linux,windows}/*/
rm -rf {linux,windows}/.icon*
rm -rf {linux,windows}/builder-debug.yml
- name: ls dirs
run: ls linux && ls windows
- name: Get some values needed for the release
id: vars
shell: bash
run: |
echo "::set-output name=releaseTag::$(git describe --tags --abbrev=0)"
- name: Create Release
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
const release = await github.repos.createRelease({
owner, repo,
tag_name: process.env.releaseTag,
draft: true,
target_commitish: sha
});
console.log('created release', { release });
for (let file of await fs.readdir('linux')) {
// do whatever filtering you want here, I'm just uploading all the files
console.log('uploading', file);
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./linux/${file}`)
});
}
for (let file of await fs.readdir('windows')) {
// do whatever filtering you want here, I'm just uploading all the files
console.log('uploading', file);
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./windows/${file}`)
});
}
env:
releaseTag: ${{ inputs.releaseTag }}