fail fast #135
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/release Electron app | |
on: | |
push: | |
branches: | |
- main | |
permissions: write-all | |
jobs: | |
release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
fail-fast: false | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
- name: Install Dependencies | |
run: npm install -g yarn | |
- name: Install yarn | |
run: yarn install | |
- name: install-snapcraft | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt update | |
sudo apt install -y snapd | |
sudo snap install core | |
sudo snap install snapcraft --classic | |
- name: build-linux | |
if: matrix.os == 'ubuntu-latest' | |
env: | |
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.STORE_LOGIN }} | |
NODE_OPTIONS: "--max_old_space_size=4096" | |
run: yarn run build:linux | |
- name: build-mac | |
if: matrix.os == 'macos-latest' | |
env: | |
NODE_OPTIONS: "--max_old_space_size=4096" | |
run: yarn run build:mac | |
- name: build-win | |
if: matrix.os == 'windows-latest' | |
env: | |
NODE_OPTIONS: "--max_old_space_size=4096" | |
run: yarn run build:win | |
# Step 5: Upload only specific release artifacts | |
- name: Upload artifacts for release | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifacts-${{ matrix.os }} | |
path: | | |
dist/*.exe # Windows executable | |
dist/*.dmg # macOS disk image | |
dist/*.AppImage # Linux AppImage | |
dist/*.snap # Linux snap package | |
dist/*.deb # Debian package | |
dist/*.rpm # RPM package | |
dist/*.tar.gz # Compressed tarball | |
publish-and-release: | |
needs: release | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Download all artifacts from matrix jobs | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: all-artifacts | |
# Step 2: Set the release name with timestamp | |
- name: Set Release Name | |
id: release_name | |
run: echo "RELEASE_NAME=Release $(date +"%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV | |
# Step 3: Publish the NPM package (once, after matrix completes) | |
- name: Publish to NPM | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm publish --access public | |
# Step 4: Create GitHub Release and upload all artifacts | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
all-artifacts/**/* | |
tag_name: "v${{ github.run_number }}" | |
name: "${{ env.RELEASE_NAME }}" | |
prerelease: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |