release.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. name: Release
  2. on:
  3. workflow_dispatch:
  4. push:
  5. tags:
  6. - v*
  7. jobs:
  8. build:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - uses: actions/checkout@v1 # v1 keeps tags
  12. with:
  13. fetch-depth: 250 # for `action-helper`
  14. # persist-credentials: false # not implemented in v1
  15. - uses: actions/setup-node@v2
  16. with:
  17. node-version: '18'
  18. - name: Prepare
  19. run: yarn && node scripts/action-helper.js
  20. env:
  21. ACTION_BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
  22. DISCORD_WEBHOOK_RELEASE: ${{ secrets.DISCORD_WEBHOOK_RELEASE }}
  23. - name: Build
  24. env:
  25. SYNC_DROPBOX_CLIENT_ID: ${{ secrets.SYNC_DROPBOX_CLIENT_ID }}
  26. SYNC_GOOGLE_CLIENT_ID: ${{ secrets.SYNC_GOOGLE_CLIENT_ID }}
  27. SYNC_GOOGLE_CLIENT_SECRET: ${{ secrets.SYNC_GOOGLE_CLIENT_SECRET }}
  28. SYNC_GOOGLE_DESKTOP_ID: ${{ secrets.SYNC_GOOGLE_DESKTOP_ID }}
  29. SYNC_GOOGLE_DESKTOP_SECRET: ${{ secrets.SYNC_GOOGLE_DESKTOP_SECRET }}
  30. SYNC_ONEDRIVE_CLIENT_ID: ${{ secrets.SYNC_ONEDRIVE_CLIENT_ID }}
  31. SYNC_ONEDRIVE_CLIENT_SECRET: ${{ secrets.SYNC_ONEDRIVE_CLIENT_SECRET }}
  32. run: |
  33. mkdir -p $ASSETS_DIR $TEMP_DIR
  34. # Create source zip
  35. git archive @ --format=zip > $TEMP_DIR/$SOURCE_ZIP
  36. # Include .env to ensure the output is reproducible
  37. export | grep SYNC_ | sed -e 's/^declare -x //' > .env \
  38. && zip -u $TEMP_DIR/$SOURCE_ZIP .env && rm .env
  39. # Build for release, also upload to GitHub assets
  40. yarn build
  41. # Build one more time to make sure the output is the same
  42. mv dist $TEMP_DIR/dist && yarn build && diff -qr dist $TEMP_DIR/dist
  43. cd dist && zip -r ../$ASSETS_DIR/$ASSET_ZIP . && cd ..
  44. # Build for CWS beta, append `BETA` to version name
  45. # Same as `BETA=1 yarn build` but only manifest is changed by now
  46. BETA=1 npx gulp manifest
  47. cd dist && zip -r ../$TEMP_DIR/$ASSET_CWS_BETA_ZIP . && cd ..
  48. # Build for AMO unlisted, append `BETA` to version name and set update_url for FF
  49. # Same as `yarn build:selfHosted` but only manifest is changed by now
  50. TARGET=selfHosted BETA=1 npx gulp manifest
  51. cd dist && zip -r ../$TEMP_DIR/$ASSET_SELF_HOSTED_ZIP . && cd ..
  52. - name: Publish to AMO
  53. id: signAMO
  54. continue-on-error: true
  55. run: |
  56. mkdir -p $TEMP_DIR/updates
  57. if [ "$PRERELEASE" != "true" ]; then
  58. echo Publish listed version
  59. # Ignore error since we don't need to download it
  60. node scripts/amo-upload.mjs
  61. else
  62. echo Publish unlisted version
  63. DEBUG=amo-upload BETA=1 node scripts/amo-upload.mjs
  64. fi
  65. env:
  66. AMO_KEY: ${{ secrets.AMO_KEY }}
  67. AMO_SECRET: ${{ secrets.AMO_SECRET }}
  68. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. - name: Update updates.json
  70. uses: JamesIves/[email protected]
  71. if: steps.signAMO.outcome == 'success'
  72. with:
  73. branch: updates
  74. folder: ${{ env.TEMP_DIR }}/updates
  75. commit-message: Update to ${{ env.VERSION }} 🚀
  76. - name: Publish to CWS
  77. continue-on-error: true
  78. run: |
  79. set -x
  80. if [ "$PRERELEASE" != "true" ]; then
  81. echo Publish release
  82. npx chrome-webstore-upload-cli@1 upload --extension-id $EXTENSION_ID_RELEASE --source $ASSETS_DIR/$ASSET_ZIP --auto-publish
  83. else
  84. echo Publish prerelease
  85. npx chrome-webstore-upload-cli@1 upload --extension-id $EXTENSION_ID_BETA --source $TEMP_DIR/$ASSET_CWS_BETA_ZIP --auto-publish
  86. fi
  87. env:
  88. EXTENSION_ID_BETA: opokoaglpekkimldnlggpoagmjegichg
  89. EXTENSION_ID_RELEASE: jinjaccalgkegednnccohejagnlnfdag
  90. CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
  91. CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
  92. REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
  93. - name: Create/Update Release
  94. env:
  95. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  96. run: |
  97. node -e 'import("./scripts/release-helper.mjs").then(({ uploadAssets }) => uploadAssets())';