release.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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_GOOGLE_CLIENT_ID: ${{ secrets.SYNC_GOOGLE_CLIENT_ID }}
  22. SYNC_GOOGLE_CLIENT_SECRET: ${{ secrets.SYNC_GOOGLE_CLIENT_SECRET }}
  23. SYNC_ONEDRIVE_CLIENT_ID: ${{ secrets.SYNC_ONEDRIVE_CLIENT_ID }}
  24. SYNC_ONEDRIVE_CLIENT_SECRET: ${{ secrets.SYNC_ONEDRIVE_CLIENT_SECRET }}
  25. run: |
  26. mkdir -p $ASSETS_DIR $TEMP_DIR
  27. # Create source zip
  28. git archive @ --format=zip > $TEMP_DIR/$SOURCE_ZIP
  29. # Build for release, also upload to GitHub assets
  30. yarn build
  31. cd dist && zip -r ../$ASSETS_DIR/$ASSET_ZIP . && cd ..
  32. # Build for CWS beta, append `BETA` to version name
  33. # Same as `BETA=1 yarn build` but only manifest is changed by now
  34. BETA=1 npx gulp manifest
  35. cd dist && zip -r ../$TEMP_DIR/$ASSET_CWS_BETA_ZIP . && cd ..
  36. # Build for AMO unlisted, append `BETA` to version name and set update_url for FF
  37. # Same as `yarn build:selfHosted` but only manifest is changed by now
  38. TARGET=selfHosted BETA=1 npx gulp manifest
  39. cd dist && zip -r ../$TEMP_DIR/$ASSET_SELF_HOSTED_ZIP . && cd ..
  40. - name: Publish to AMO
  41. id: signAMO
  42. continue-on-error: true
  43. run: |
  44. mkdir -p $TEMP_DIR/updates
  45. if [ "$PRERELEASE" != "true" ]; then
  46. # Publish listed version, ignore error since we don't need to download it
  47. node scripts/amo-upload.mjs || 0
  48. fi
  49. # Publish unlisted version
  50. BETA=1 node scripts/amo-upload.mjs
  51. env:
  52. AMO_KEY: ${{ secrets.AMO_KEY }}
  53. AMO_SECRET: ${{ secrets.AMO_SECRET }}
  54. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  55. - name: Update updates.json
  56. uses: JamesIves/[email protected]
  57. if: steps.signAMO.outcome == 'success'
  58. with:
  59. branch: updates
  60. folder: ${{ env.TEMP_DIR }}/updates
  61. commit-message: Update to ${{ env.VERSION }} 🚀
  62. - name: Publish to CWS
  63. continue-on-error: true
  64. run: |
  65. set -x
  66. if [ "$PRERELEASE" != "true" ]; then
  67. # Publish release
  68. npx chrome-webstore-upload-cli@1 upload --extension-id $EXTENSION_ID_RELEASE --source $ASSETS_DIR/$ASSET_ZIP --auto-publish
  69. fi
  70. # Always publish prerelease
  71. npx chrome-webstore-upload-cli@1 upload --extension-id $EXTENSION_ID_BETA --source $TEMP_DIR/$ASSET_CWS_BETA_ZIP --auto-publish
  72. env:
  73. EXTENSION_ID_BETA: opokoaglpekkimldnlggpoagmjegichg
  74. EXTENSION_ID_RELEASE: jinjaccalgkegednnccohejagnlnfdag
  75. CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
  76. CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
  77. REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
  78. - name: Create/Update Release
  79. env:
  80. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  81. run: |
  82. node -e 'require("./scripts/release-helper").uploadAssets()';