Create GitHub Release #69
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: Create GitHub Release | |
on: workflow_dispatch | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [windows-latest, macos-latest] | |
name: Build (${{ matrix.os }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout ${{ github.repository }} @ ${{ github.ref }} | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
ref: ${{ github.ref }} | |
fetch-depth: 1 | |
- name: Install NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Install NPM Packages | |
run: npm install | |
- name: Build Application | |
run: npm run bundle --workspace app/nw --workspace app/electron | |
- name: Upload NW Builds | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bundle-nw-${{ matrix.os }} | |
retention-days: 3 | |
path: app/nw/bundle/ | |
- name: Upload Electron Builds | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bundle-electron-${{ matrix.os }} | |
retention-days: 3 | |
path: app/electron/bundle/ | |
release-notes: | |
needs: build | |
name: Prepare Release Notes | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ${{ github.repository }} @ ${{ github.ref }} | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
ref: ${{ github.ref }} | |
fetch-depth: 1 | |
- name: Upload Release Templates | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-templates | |
retention-days: 3 | |
path: .github/RELEASE_TEMPLATE/*.md | |
publish: | |
needs: | |
- build | |
- release-notes | |
name: Publish Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Environment | |
run: | | |
echo "RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV | |
echo "RELEASE_TAG=$(date -u +"%y%m%dT%H%M")" >> $GITHUB_ENV | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create Release Description | |
run: | | |
DESCRIPTION=$(cat ./release-templates/pre-release.md | jq -sR | sed s/{TAG}/$RELEASE_TAG/g) | |
DESCRIPTION=$(echo $DESCRIPTION | sed s/{WIN_64_ZIP}/$(ls ./bundle-nw-* | grep 'x64.zip')/g) | |
DESCRIPTION=$(echo $DESCRIPTION | sed s/{WIN_32_ZIP}/$(ls ./bundle-nw-* | grep 'ia32.zip')/g) | |
DESCRIPTION=$(echo $DESCRIPTION | sed s/{MACOS_X64_DMG}/$(ls ./bundle-nw-* | grep 'x64.dmg')/g) | |
DESCRIPTION=$(echo $DESCRIPTION | sed s/{MACOS_ARM64_DMG}/$(ls ./bundle-nw-* | grep 'arm64.dmg')/g) | |
echo -n $DESCRIPTION > ./release-templates/description.md | |
- name: Create Release Tag | |
run: | | |
echo { > ./body.json | |
echo \"prerelease\":true, >> ./body.json | |
echo \"tag_name\":\"$RELEASE_TAG\", >> ./body.json | |
echo \"name\":\"canary • $RELEASE_DATE\", >> ./body.json | |
echo \"body\":$(cat ./release-templates/description.md) >> ./body.json | |
echo } >> ./body.json | |
echo +++ REQUEST +++ | |
cat ./body.json | |
echo -n "RELEASE_ID=" >> $GITHUB_ENV | |
curl \ | |
-X POST \ | |
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
'https://api.github.com/repos/${{ github.repository }}/releases' \ | |
--data @./body.json \ | |
--silent > ./response.json | |
echo +++ RESPONSE +++ | |
cat ./response.json | |
cat ./response.json | grep '"upload_url"' | cut -d'/' -f8 >> $GITHUB_ENV | |
rm body.json response.json | |
- name: Upload Release Assets | |
run: | | |
for FILE in ./bundle-*/*.*; do \ | |
curl \ | |
-X POST \ | |
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
-H 'Content-Type: application/octet-stream' \ | |
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ env.RELEASE_ID }}/assets?name=$(basename $FILE)" \ | |
--data-binary @"$FILE" \ | |
--silent \ | |
&& echo \ | |
; done |