diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml new file mode 100644 index 000000000..772ce81d6 --- /dev/null +++ b/.github/workflows/build-artifacts.yml @@ -0,0 +1,115 @@ +name: Build artifacts + +on: + release: + types: [published] + +env: + GH_TOKEN: ${{ github.token }} + +jobs: + build-windows: + name: Build Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - name: Install npm dependencies + run: npm ci + - name: Build the production app + shell: bash + run: npm run build + - name: Build the Electron app + shell: bash + run: npm run electron-win + - name: Zip + shell: bash + run: cd .build; for i in bitburner-*; do 7z a "$i.zip" "$i"; done; cd ../; + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-win + include-hidden-files: true + path: .build/*.zip + if-no-files-found: error + + build-linux: + name: Build Linux + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - name: Install npm dependencies + run: npm ci + - name: Build the production app + run: npm run build + - name: Build the Electron app + run: npm run electron-linux + - name: Zip + run: cd .build; for i in bitburner-*; do zip -r "$i.zip" "$i"; done; cd ../; + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-linux + include-hidden-files: true + path: .build/*.zip + if-no-files-found: error + + build-mac: + name: Build macOS + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - name: Install npm dependencies + run: npm ci + - name: Build the production app + run: npm run build + - name: Build the Electron app + run: npm run electron-mac + - name: Zip + run: cd .build; for i in bitburner-*; do zip -r "$i.zip" "$i"; done; cd ../; + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-mac + include-hidden-files: true + path: .build/*.zip + if-no-files-found: error + + upload: + name: Upload + runs-on: ubuntu-latest + needs: [build-windows, build-linux, build-mac] + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: .build + pattern: build-artifacts-* + merge-multiple: true + - name: List files + run: ls -la .build + - name: Upload to release + env: + GH_REF_NAME: ${{ github.ref_name }} + run: | + for i in .build/*.zip; do gh release upload "$GH_REF_NAME" "$i" --clobber; done; diff --git a/electron/icon.png b/electron/icon.png index d052a0b91..175ffc8b7 100644 Binary files a/electron/icon.png and b/electron/icon.png differ diff --git a/package.json b/package.json index e0b60f18e..28052fd1c 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,9 @@ "watch": "webpack --watch --mode production", "watch:dev": "webpack --watch --mode development", "electron": "bash ./tools/package-electron.sh", - "electron:packager-all": "electron-packager .package bitburner --platform all --arch x64,armv7l,arm64,mips64el --out .build --overwrite --icon .package/icon.png --app-copyright \"Copyright (C) 2024 Bitburner\"", + "electron-win": "bash ./tools/package-electron.sh win", + "electron-linux": "bash ./tools/package-electron.sh linux", + "electron-mac": "bash ./tools/package-electron.sh mac", "preversion": "npm install && npm run test", "version": "sh ./tools/build-release.sh && git add --all", "postversion": "git push -u origin dev && git push --tags", diff --git a/tools/package-electron.sh b/tools/package-electron.sh index b06a6dc7e..8dfb38c4e 100755 --- a/tools/package-electron.sh +++ b/tools/package-electron.sh @@ -17,4 +17,13 @@ cp -r electron/* .package BUILD_PLATFORM="${1:-"all"}" # And finally build the app. -npm run electron:packager-$BUILD_PLATFORM +case $BUILD_PLATFORM in + "win") + electron-packager .package bitburner --platform win32 --arch x64,arm64 --out .build --overwrite --icon .package/icon.ico --app-copyright "Copyright (C) 2024 Bitburner";; + "linux") + electron-packager .package bitburner --platform linux --arch x64,arm64 --out .build --overwrite --app-copyright "Copyright (C) 2024 Bitburner";; + "mac") + electron-packager .package bitburner --platform darwin --arch x64,arm64 --out .build --overwrite --icon .package/icon.icns --app-copyright "Copyright (C) 2024 Bitburner";; + *) + electron-packager .package bitburner --platform win32,linux,darwin --arch x64,arm64 --out .build --overwrite --icon .package/icon --app-copyright "Copyright (C) 2024 Bitburner";; +esac