release.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. # Include .env to ensure the output is reproducible
  33. export | grep SYNC_ | sed -e 's/^declare -x //' > .env \
  34. && zip -u $TEMP_DIR/$SOURCE_ZIP .env && rm .env
  35. # Build for release, also upload to GitHub assets
  36. yarn build
  37. # Build one more time to make sure the output is the same
  38. mv dist $TEMP_DIR/dist && yarn build && diff -qr dist $TEMP_DIR/dist
  39. cd dist && zip -r ../$ASSETS_DIR/$ASSET_ZIP . && cd ..
  40. # Build for CWS beta, append `BETA` to version name
  41. # Same as `BETA=1 yarn build` but only manifest is changed by now
  42. BETA=1 npx gulp manifest
  43. cd dist && zip -r ../$TEMP_DIR/$ASSET_CWS_BETA_ZIP . && cd ..
  44. # Build for AMO unlisted, append `BETA` to version name and set update_url for FF
  45. # Same as `yarn build:selfHosted` but only manifest is changed by now
  46. TARGET=selfHosted BETA=1 npx gulp manifest
  47. cd dist && zip -r ../$TEMP_DIR/$ASSET_SELF_HOSTED_ZIP . && cd ..
  48. - name: Publish to AMO
  49. id: signAMO
  50. continue-on-error: true
  51. run: |
  52. mkdir -p $TEMP_DIR/updates
  53. if [ "$PRERELEASE" != "true" ]; then
  54. echo Publish listed version
  55. # Ignore error since we don't need to download it
  56. node scripts/amo-upload.mjs
  57. else
  58. echo Publish unlisted version
  59. BETA=1 node scripts/amo-upload.mjs
  60. fi
  61. env:
  62. AMO_KEY: ${{ secrets.AMO_KEY }}
  63. AMO_SECRET: ${{ secrets.AMO_SECRET }}
  64. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  65. - name: Update updates.json
  66. uses: JamesIves/[email protected]
  67. if: steps.signAMO.outcome == 'success'
  68. with:
  69. branch: updates
  70. folder: ${{ env.TEMP_DIR }}/updates
  71. commit-message: Update to ${{ env.VERSION }} 🚀
  72. - name: Publish to CWS
  73. continue-on-error: true
  74. run: |
  75. set -x
  76. if [ "$PRERELEASE" != "true" ]; then
  77. echo Publish release
  78. npx chrome-webstore-upload-cli@1 upload --extension-id $EXTENSION_ID_RELEASE --source $ASSETS_DIR/$ASSET_ZIP --auto-publish
  79. else
  80. echo Publish prerelease
  81. npx chrome-webstore-upload-cli@1 upload --extension-id $EXTENSION_ID_BETA --source $TEMP_DIR/$ASSET_CWS_BETA_ZIP --auto-publish
  82. fi
  83. env:
  84. EXTENSION_ID_BETA: opokoaglpekkimldnlggpoagmjegichg
  85. EXTENSION_ID_RELEASE: jinjaccalgkegednnccohejagnlnfdag
  86. CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
  87. CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
  88. REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
  89. - name: Create/Update Release
  90. env:
  91. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  92. run: |
  93. node -e 'require("./scripts/release-helper").uploadAssets()';