diff --git a/.github/actions/init-template-with-renderer/action.yml b/.github/actions/init-template-with-renderer/action.yml index 3f7e59c00..d921a1754 100644 --- a/.github/actions/init-template-with-renderer/action.yml +++ b/.github/actions/init-template-with-renderer/action.yml @@ -1,11 +1,11 @@ -name: 'Init template with all dependencies renderer' -description: 'Install all necessary dependencies and init a renderer package' +name: Setup boilerplate inputs: renderer-template: - description: 'type of renderer package to init' + description: Define what vite template should be used to create renderer in case if renderer package doesn't exist required: false default: '' + runs: using: "composite" steps: @@ -19,19 +19,21 @@ runs: with: node-version: 'latest' - - run: npm run create-renderer -- -- --template ${{inputs.renderer-template}} - shell: bash - if: inputs.renderer-template != '' - - - run: npm start --workspace @vite-electron-builder/integrate-renderer + - name: Check if renderer directory exists + id: check-renderer + run: >- + if [ -d "packages/renderer" ]; then + echo "RENDERER_EXIST=true" >> $GITHUB_OUTPUT + else + echo "RENDERER_EXIST=false" >> $GITHUB_OUTPUT + fi shell: bash - if: inputs.renderer-template != '' - run: | - mkdir packages/renderer - echo "{\"name\":\"@vite-electron-builder/renderer\"}" > packages/renderer/package.json + npm run create-renderer -- -- --template ${{inputs.renderer-template}} + npm start --workspace @vite-electron-builder/integrate-renderer shell: bash - if: inputs.renderer-template == '' + if: inputs.renderer-template != '' && steps.check-renderer.outputs.RENDERER_EXIST == 'false' - name: Cache Dependencies uses: actions/cache@v4 @@ -41,5 +43,11 @@ runs: restore-keys: | npm-${{ runner.os }}-${{ inputs.renderer-template }}- - - run: npm install + - name: Install Dependencies + run: >- + if [ "${{ steps.check-renderer.outputs.RENDERER_EXIST }}" == "true" ] && [ -f "package-lock.json" ]; then + npm ci + else + npm install + fi shell: bash diff --git a/.github/workflows/boilerplate-ci-entry.yml b/.github/workflows/boilerplate-ci-entry.yml new file mode 100644 index 000000000..e7545f12c --- /dev/null +++ b/.github/workflows/boilerplate-ci-entry.yml @@ -0,0 +1,71 @@ +# This file serves as a boilerplate template rather than an end-application script. +# The final application is likely to delete this file and use `ci.yml` as the entry point. + +on: + workflow_dispatch: + push: + branches: + - main + paths-ignore: + - '**.md' + - .editorconfig + - '.idea/**' + - '.vscode/**' + pull_request: + paths-ignore: + - '**.md' + - .editorconfig + - '.idea/**' + - '.vscode/**' + +concurrency: + group: ${{github.workflow}}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + +jobs: + run-ci-for-template: + name: ci.yml + uses: ./.github/workflows/ci.yml + with: + renderer-template: ${{ matrix.renderer-template }} + distribution-channel: ${{ matrix.renderer-template }} + strategy: + fail-fast: false + matrix: + renderer-template: + - vanilla + - vanilla-ts + - vue + - vue-ts + - react + - react-ts + - react-swc + - react-swc-ts + - preact + - preact-ts + - lit + - lit-ts + - svelte + - svelte-ts + - solid + - solid-ts +# - qwik +# - qwik-ts + + dependabot: + permissions: + contents: write + pull-requests: write + needs: + - run-ci-for-template + runs-on: ubuntu-latest + if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'cawa-93/vite-electron-builder' + steps: + - name: Enable auto-merge for Dependabot PRs + run: gh pr merge --auto --rebase "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d3d85f1f..22d9d3d84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,23 +1,20 @@ # This workflow is the entry point for all CI processes. # It is from here that all other workflows are launched. on: - workflow_dispatch: - push: - branches: - - main - paths-ignore: - - '**.md' - - .editorconfig - - '.idea/**' - - '.vscode/**' - pull_request: - paths-ignore: - - '**.md' - - .editorconfig - - '.idea/**' - - '.vscode/**' + workflow_call: + inputs: + distribution-channel: + description: Distribution channel for release. It can be `beta`, `alpha` or any string. + type: string + required: true + renderer-template: + description: Define what vite template should be used to create renderer in case if renderer package doesn't exist + required: false + type: string + default: '' + concurrency: - group: ${{github.workflow}}-${{ github.ref }} + group: ${{github.workflow}}-${{ github.ref }}-${{inputs.distribution-channel}} cancel-in-progress: true permissions: @@ -25,51 +22,34 @@ permissions: jobs: prepare: + name: Prepare shared data for multi-platform compilation runs-on: ubuntu-latest outputs: APP_VERSION: ${{ steps.APP_VERSION.outputs.APP_VERSION }} COMMIT_TIMESTAMP: ${{ steps.COMMIT_TIMESTAMP.outputs.COMMIT_TIMESTAMP }} + APP_FULL_VERSION: ${{ steps.APP_FULL_VERSION.outputs.APP_FULL_VERSION }} steps: - uses: actions/checkout@v4 - id: COMMIT_TIMESTAMP run: echo "COMMIT_TIMESTAMP=$(git show -s --format=%ct ${{ github.sha }})" >> $GITHUB_OUTPUT - id: APP_VERSION run: echo "APP_VERSION=$(jq -r .version package.json)" >> $GITHUB_OUTPUT + - id: APP_FULL_VERSION + run: echo "APP_FULL_VERSION=${{ steps.APP_VERSION.outputs.APP_VERSION }}-${{inputs.distribution-channel}}.${{ steps.COMMIT_TIMESTAMP.outputs.COMMIT_TIMESTAMP }}" >> $GITHUB_OUTPUT - run: | echo "- \`COMMIT_TIMESTAMP\`: ${{ steps.COMMIT_TIMESTAMP.outputs.COMMIT_TIMESTAMP }}" >> $GITHUB_STEP_SUMMARY echo "- \`APP_VERSION\`: ${{ steps.APP_VERSION.outputs.APP_VERSION }}" >> $GITHUB_STEP_SUMMARY + echo "- \`APP_FULL_VERSION\`: ${{ steps.APP_FULL_VERSION.outputs.APP_FULL_VERSION }}" >> $GITHUB_STEP_SUMMARY compile-and-test: needs: - prepare uses: ./.github/workflows/compile-and-test.yml with: - renderer-template: ${{ matrix.renderer-template }} - app-version: ${{ needs.prepare.outputs.APP_VERSION }} - build-number: ${{ needs.prepare.outputs.COMMIT_TIMESTAMP }} - strategy: - fail-fast: false - matrix: - renderer-template: - - vanilla - - vanilla-ts - - vue - - vue-ts - - react - - react-ts - - react-swc - - react-swc-ts - - preact - - preact-ts - - lit - - lit-ts - - svelte - - svelte-ts - - solid - - solid-ts -# Qwik Has unresolved upstream issue. So I decided to torn it off for now -# - qwik -# - qwik-ts + renderer-template: ${{ inputs.renderer-template }} + app-version: ${{ needs.prepare.outputs.APP_FULL_VERSION }} + distribution-channel: ${{inputs.distribution-channel}} + deploy: if: github.event_name == 'push' && github.ref == 'refs/heads/main' permissions: @@ -79,45 +59,5 @@ jobs: - compile-and-test uses: ./.github/workflows/deploy.yml with: - renderer-template: ${{ matrix.renderer-template }} - app-version: ${{ needs.prepare.outputs.APP_VERSION }} - build-number: ${{ needs.prepare.outputs.COMMIT_TIMESTAMP }} - strategy: - fail-fast: false - matrix: - renderer-template: - - vanilla - - vanilla-ts - - vue - - vue-ts - - react - - react-ts - - react-swc - - react-swc-ts - - preact - - preact-ts - - lit - - lit-ts - - svelte - - svelte-ts - - solid - - solid-ts -# Qwik Has unresolved upstream issue. So I decided to torn it off for now -# - qwik -# - qwik-ts - - - dependabot: - permissions: - contents: write - pull-requests: write - needs: - - compile-and-test - runs-on: ubuntu-latest - if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'cawa-93/vite-electron-builder' - steps: - - name: Enable auto-merge for Dependabot PRs - run: gh pr merge --auto --rebase "$PR_URL" - env: - PR_URL: ${{github.event.pull_request.html_url}} - GH_TOKEN: ${{secrets.GITHUB_TOKEN}} + distribution-channel: ${{ inputs.renderer-template }} + app-version: ${{ needs.prepare.outputs.APP_FULL_VERSION }} diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index d9531617c..56ab9b6e9 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -4,12 +4,14 @@ on: workflow_call: inputs: renderer-template: - required: true + description: Define what vite template should be used to create renderer in case if renderer package doesn't exist + required: false type: string + default: '' app-version: required: true type: string - build-number: + distribution-channel: required: true type: string @@ -29,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/init-template-with-renderer - name: Init template with "${{inputs.renderer-template}}" renderer + name: Setup boilerplate with: renderer-template: ${{inputs.renderer-template}} - run: npm run typecheck --if-present @@ -46,20 +48,19 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/init-template-with-renderer - name: Init template with "${{inputs.renderer-template}}" renderer + name: Setup boilerplate with: renderer-template: ${{inputs.renderer-template}} - - run: npm version "${{inputs.app-version}}-${{inputs.renderer-template}}.${{inputs.build-number}}" --no-git-tag-version + - run: npm version "${{inputs.app-version}}" --no-git-tag-version - run: npm run compile -- -p never env: - VITE_DISTRIBUTION_CHANNEL: ${{inputs.renderer-template}} - BUILD_NUMBER: ${{inputs.build-number}} + VITE_DISTRIBUTION_CHANNEL: ${{inputs.distribution-channel}} - run: npm run test --if-present - name: Upload compiled app uses: actions/upload-artifact@v4 with: - name: ${{ matrix.os }}-${{inputs.renderer-template}} + name: ${{ matrix.os }}-${{inputs.distribution-channel}} path: dist diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7fe67fa79..0ec29a93d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,13 +3,10 @@ name: Deploy on: workflow_call: inputs: - renderer-template: - required: true - type: string app-version: required: true type: string - build-number: + distribution-channel: required: true type: string @@ -26,22 +23,19 @@ env: npm_config_audit: false npm_config_fund: false - jobs: deploy: runs-on: ubuntu-latest environment: - name: ${{inputs.renderer-template}} - url: https://github.com/${{github.repository}}/releases/tag/v${{inputs.app-version}}-${{inputs.renderer-template}}.${{inputs.build-number}} + name: ${{inputs.distribution-channel}} + url: https://github.com/${{github.repository}}/releases/tag/v${{inputs.app-version}} steps: - - name: Set pattern variable - run: echo "pattern=*-${{inputs.renderer-template}}" >> $GITHUB_ENV - name: Download compiled app uses: actions/download-artifact@v4 with: - pattern: "*-${{inputs.renderer-template}}" + pattern: "*-${{inputs.distribution-channel}}" path: dist merge-multiple: true - - run: gh release create v${{inputs.app-version}}-${{inputs.renderer-template}}.${{inputs.build-number}} dist/*${{inputs.renderer-template}}* dist/latest*.yml --repo ${{github.repository}} + - run: gh release create v${{inputs.app-version}} dist/root* dist/latest*.yml --repo ${{github.repository}} env: GH_TOKEN: ${{ github.token }} diff --git a/electron-builder.mjs b/electron-builder.mjs index 15c68c4a0..a79b50534 100644 --- a/electron-builder.mjs +++ b/electron-builder.mjs @@ -13,6 +13,11 @@ export default /** @type import('electron-builder').Configuration */ linux: { target: ['deb'], }, + /** + * It is recommended to avoid using non-standard characters such as spaces in artifact names, + * as they can unpredictably change during deployment, making them impossible to locate and download for update. + */ + artifactName: '${productName}-${version}-${os}-${arch}.${ext}', files: [ 'packages/entry-point.js', '!node_modules/@vite-electron-builder/**',