release.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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@v3
  16. with:
  17. node-version: '20'
  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_DESKTOP_ID: ${{ secrets.SYNC_GOOGLE_DESKTOP_ID }}
  27. SYNC_GOOGLE_DESKTOP_SECRET: ${{ secrets.SYNC_GOOGLE_DESKTOP_SECRET }}
  28. SYNC_ONEDRIVE_CLIENT_ID: ${{ secrets.SYNC_ONEDRIVE_CLIENT_ID }}
  29. run: |
  30. mkdir -p $ASSETS_DIR $TEMP_DIR
  31. # Create source zip
  32. git archive @ --format=zip > $TEMP_DIR/$SOURCE_ZIP
  33. # Include .env to ensure the output is reproducible
  34. export | grep SYNC_ | sed -e 's/^declare -x //' > .env \
  35. && zip -u $TEMP_DIR/$SOURCE_ZIP .env && rm .env
  36. # Build for release, also upload to GitHub assets
  37. yarn build
  38. # Build one more time to make sure the output is the same
  39. mv dist $TEMP_DIR/dist && yarn build && diff -qr dist $TEMP_DIR/dist
  40. cd dist && zip -r ../$ASSETS_DIR/$ASSET_ZIP . && cd ..
  41. # Build for CWS beta, append `BETA` to version name
  42. # Same as `BETA=1 yarn build` but only manifest is changed by now
  43. BETA=1 npx gulp manifest
  44. cd dist && zip -r ../$TEMP_DIR/$ASSET_CWS_BETA_ZIP . && cd ..
  45. # Build for AMO unlisted, append `BETA` to version name and set update_url for FF
  46. # Same as `yarn build:selfHosted` but only manifest is changed by now
  47. TARGET=selfHosted BETA=1 npx gulp manifest
  48. cd dist && zip -r ../$TEMP_DIR/$ASSET_SELF_HOSTED_ZIP . && cd ..
  49. - name: Publish to AMO
  50. continue-on-error: true
  51. run: |
  52. mkdir -p $TEMP_DIR/updates
  53. if [ "$PRERELEASE" != "true" ]; then
  54. echo Publish listed version
  55. node scripts/amo-upload.mjs
  56. else
  57. echo Publish unlisted version
  58. DEBUG=amo-upload BETA=1 node scripts/amo-upload.mjs
  59. fi
  60. env:
  61. AMO_KEY: ${{ secrets.AMO_KEY }}
  62. AMO_SECRET: ${{ secrets.AMO_SECRET }}
  63. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  64. # Try to publish if not exist
  65. AMO_PUBLISH: true
  66. - name: Publish to CWS
  67. continue-on-error: true
  68. run: |
  69. set -x
  70. if [ "$PRERELEASE" != "true" ]; then
  71. echo Publish release
  72. npx chrome-webstore-upload-cli@1 upload --extension-id $EXTENSION_ID_RELEASE --source $ASSETS_DIR/$ASSET_ZIP --auto-publish
  73. else
  74. echo Publish prerelease
  75. npx chrome-webstore-upload-cli@1 upload --extension-id $EXTENSION_ID_BETA --source $TEMP_DIR/$ASSET_CWS_BETA_ZIP --auto-publish
  76. fi
  77. env:
  78. EXTENSION_ID_BETA: opokoaglpekkimldnlggpoagmjegichg
  79. EXTENSION_ID_RELEASE: jinjaccalgkegednnccohejagnlnfdag
  80. CLIENT_ID: ${{ secrets.CWS_CLIENT_ID }}
  81. CLIENT_SECRET: ${{ secrets.CWS_CLIENT_SECRET }}
  82. REFRESH_TOKEN: ${{ secrets.CWS_REFRESH_TOKEN }}
  83. - name: Create/Update Release
  84. env:
  85. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  86. run: |
  87. node -e 'import("./scripts/release-helper.mjs").then(({ uploadAssets }) => uploadAssets())';