release.yml 3.6 KB

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