Electron-Builder installers for multi platforms

Building an electron app on three platforms. The tool electron-builder will produce installers with names like these two for Ubuntu and Windows:

  • my-app\_1.0.1\_amd64.deb

  • my-app Setup 1.0.1.exe

The version string comes its package.json. And I want to run the workflow when I push the tag for v1.0.1.

I have not been able to figure out a way to set the artifact and asset names to contain the version string (not semver).

At the moment, I am hard-coding the version into the workflow itself. Then using action svenstaro/upload-release-action@v1-release to upload the tag.

Here is the start of the workflow and below that is the uploading action.

name: build and release electron from react web  

      - 'v\*' # any push with a tag in semver format
    name: build-electron-from-react-web
      VERSION: 1.0.1  

    # update versions below
    runs-on: ${{ matrix.os }}
        os: [ubuntu-latest, windows-latest, macos-latest]
          - os: ubuntu-latest
            artifact\_name: book-package-app\_1.0.1\_amd64.deb
            asset\_name: book-package-app\_1.0.1\_amd64.deb
          - os: windows-latest
            artifact\_name: "book-package-app Setup 1.0.1.exe"
            asset\_name: "book-package-app Setup 1.0.1.exe"

The uploading action:

      - name: Upload Release Assets
        uses: svenstaro/upload-release-action@v1-release
          GITHUB\_TOKEN: ${{ secrets.GITHUB\_TOKEN }}
          repo\_token: ${{ secrets.GITHUB\_TOKEN }}
          file: "./electron/dist/${{ matrix.artifact\_name }}"
          asset\_name: ${{ matrix.asset\_name }}
          tag: ${{ github.ref }}
          overwrite: true

Hi @mandolyte ,

Thank you for being here!

  1. ‘Workflow&Job level env’ and matrix doesn’t accept variables, hence you can set the artifacts/asset name in step level.

2. The version string comes its package.json. And I want to run the workflow when I push the tag for v1.0.1.

>> You can get the tag version from ‘${GITHUB_REF##*v}’, and compare the value in ‘package.json’, use if expression to execute the next steps accordingly.

In total, i assume your script can be changed as below(I removed macos part you can add accordingly).

    name: build-electron-from-react-web
# env:
# VERSION: 1.0.1

    # update versions below
    runs-on: ${{ matrix.os }}
        os: [ubuntu-latest, windows-latest]
 # include:
 # - os: ubuntu-latest
 # artifact_name: book-package-app_1.0.1_amd64.deb
 # asset_name: book-package-app_1.0.1_amd64.deb
 # - os: windows-latest
 # artifact_name: "book-package-app Setup 1.0.1.exe"
 # asset_name: "book-package-app Setup 1.0.1.exe"

      - name: checkout
        uses: actions/checkout@v2
      - name: set tag version #If needed, here you can can compare the value form package.json with ${GITHUB_REF##*v}.
        shell: bash
        run: |
          echo "::set-env name=version::${GITHUB_REF##*v}"

      - name: set artifact&asset name for ubuntu
        if: runner.os=='linux'
        run: |
          echo "::set-env name=artifactname::book-package-app_${version}_amd64.deb"
          echo "::set-env name=assetname::book-package-app_${version}_amd64.deb"
      - name: set artifact&asset name for windows
        shell: bash
        if: runner.os=='windows'
        run: |
          echo "::set-env name=artifactname::book-package-app Setup ${version}.exe"
          echo "::set-env name=assetname::book-package-app Setup ${version}.exe"
      - name: Upload Release Assets
        uses: svenstaro/upload-release-action@v1-release
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          file: "./electron/dist/${{ env.artifactname }}"
          asset_name: ${{ env.assetname }}
          tag: ${{ github.ref }}
          overwrite: true

Hope it helps!

1 Like


I think I spoke too soon. Looks like env vars are not allowed where I need them. Hope you have another idea!

Annotation 2020-03-26 112754.png

Hi @mandolyte ,

Thanks for your reply! The env value to get in action ‘with’ should use the format : ${{ env.artifactname }}

I have changed in my first post, thanks.


1 Like