Skip to content

Create GitHub Release #52

Create GitHub Release

Create GitHub Release #52

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
- name: Upload Release Builds
uses: actions/upload-artifact@v4
with:
name: bundle-${{ matrix.os }}
retention-days: 3
path: app/nw/bundle
- name: Upload Release Templates
uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows-latest' }}
with:
name: release-templates
retention-days: 3
path: .github/RELEASE_TEMPLATE/*.md
publish:
needs: build
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 | tr '\r\n' '\\n' | sed s/{TAG}/$RELEASE_TAG/g)
DESCRIPTION=$(echo $DESCRIPTION | sed s/{WIN_64_ZIP}/$(ls ./bundle-* | grep 'x64.zip')/g)
DESCRIPTION=$(echo $DESCRIPTION | sed s/{WIN_32_ZIP}/$(ls ./bundle-* | grep 'ia32.zip')/g)
DESCRIPTION=$(echo $DESCRIPTION | sed s/{MACOS_X64_DMG}/$(ls ./bundle-* | grep 'x64.dmg')/g)
DESCRIPTION=$(echo $DESCRIPTION | sed s/{MACOS_ARM64_DMG}/$(ls ./bundle-* | 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