release.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. name: Release
  2. on: [workflow_call, workflow_dispatch]
  3. concurrency:
  4. group: release-${{ github.ref }}
  5. cancel-in-progress: true
  6. defaults:
  7. run:
  8. shell: 'bash'
  9. jobs:
  10. draft:
  11. runs-on: ubuntu-latest
  12. outputs:
  13. release-note: ${{ steps.release-note.outputs.release-note }}
  14. version: ${{ steps.version.outputs.build-version }}
  15. steps:
  16. - uses: actions/checkout@v3
  17. with:
  18. fetch-depth: 0
  19. - uses: actions/setup-node@v3
  20. with:
  21. node-version: 14
  22. - name: Get last git tag
  23. id: tag
  24. run: echo "::set-output name=last-tag::$(git describe --tags --abbrev=0 || git rev-list --max-parents=0 ${{github.ref}})"
  25. - name: Generate release notes
  26. uses: ./.github/actions/release-notes
  27. id: release-note
  28. with:
  29. from: ${{ steps.tag.outputs.last-tag }}
  30. to: ${{ github.ref }}
  31. include-commit-body: true
  32. include-abbreviated-commit: true
  33. - name: Get version from current date
  34. id: version
  35. run: echo "::set-output name=build-version::$(node -e "try{console.log(require('./.electron-builder.config.js').extraMetadata.version)}catch(e){console.error(e);process.exit(1)}")"
  36. - name: Delete outdated drafts
  37. uses: hugo19941994/delete-draft-releases@v1.0.0
  38. env:
  39. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  40. - name: Create Release Draft
  41. uses: softprops/action-gh-release@v1
  42. env:
  43. GITHUB_TOKEN: ${{ secrets.github_token }}
  44. with:
  45. prerelease: true
  46. draft: true
  47. tag_name: v${{ steps.version.outputs.build-version }}
  48. name: v${{ steps.version.outputs.build-version }}
  49. body: ${{ steps.release-note.outputs.release-note }}
  50. upload_artifacts:
  51. needs: [ draft ]
  52. strategy:
  53. matrix:
  54. os: [ windows-latest ]
  55. # To compile the application for different platforms, use:
  56. # os: [ macos-latest, ubuntu-latest, windows-latest ]
  57. runs-on: ${{ matrix.os }}
  58. steps:
  59. - uses: actions/checkout@v3
  60. - uses: actions/setup-node@v3
  61. with:
  62. node-version: 16 # Need for npm >=7.7
  63. cache: 'npm'
  64. - name: Install dependencies
  65. run: npm ci
  66. # The easiest way to transfer release notes to a compiled application is create `release-notes.md` in the build resources.
  67. # See https://github.com/electron-userland/electron-builder/issues/1511#issuecomment-310160119
  68. - name: Prepare release notes
  69. env:
  70. RELEASE_NOTE: ${{ needs.draft.outputs.release-note }}
  71. run: echo "$RELEASE_NOTE" >> ./buildResources/release-notes.md
  72. # Compile app and upload artifacts
  73. - name: Compile & release Electron app
  74. uses: samuelmeuli/action-electron-builder@v1
  75. env:
  76. VITE_APP_VERSION: ${{ needs.draft.outputs.version }}
  77. with:
  78. build_script_name: build
  79. args: --config .electron-builder.config.js
  80. # GitHub token, automatically provided to the action
  81. # (No need to define this secret in the repo settings)
  82. github_token: ${{ secrets.github_token }}
  83. # If the commit is tagged with a version (e.g. "v1.0.0"),
  84. # release the app after building
  85. release: true
  86. # Sometimes the build may fail due to a connection problem with Apple, GitHub, etc. servers.
  87. # This option will restart the build as many attempts as possible
  88. max_attempts: 3
  89. # Code Signing params
  90. # Base64-encoded code signing certificate for Windows
  91. # windows_certs: ''
  92. # Password for decrypting `windows_certs`
  93. # windows_certs_password: ''
  94. # Base64-encoded code signing certificate for macOS
  95. # mac_certs: ''
  96. # Password for decrypting `mac_certs`
  97. # mac_certs_password: ''