Просмотр исходного кода

chore: build and upload self-hosted version

Gerald 5 лет назад
Родитель
Сommit
7fb67b221b
3 измененных файлов с 20 добавлено и 26 удалено
  1. 17 23
      .github/workflows/release.yml
  2. 2 1
      gulpfile.js
  3. 1 2
      scripts/action-helper.js

+ 17 - 23
.github/workflows/release.yml

@@ -15,32 +15,26 @@ jobs:
       - uses: actions/setup-node@v2-beta
         with:
           node-version: '15'
-      - name: Install deps
-        run: yarn
-      - name: Prepare environment variables
-        run: node scripts/action-helper.js
+      - name: Prepare
+        run: yarn && node scripts/action-helper.js
       - name: Build
         run: |
           yarn build
-          cd dist && zip -r ../$RELEASE_FILENAME.zip .
+          cd dist && zip -r ../$RELEASE_PREFIX-v$VERSION.zip . && cd ..
+
+          # Same as `yarn build:selfHosted` but only manifest is changed for now
+          TARGET=selfHosted npx gulp manifest
+          cd dist && zip -r ../$RELEASE_PREFIX-ffself-v$VERSION.zip . && cd ..
       - name: Create Release
-        id: create_release
-        uses: actions/create-release@v1
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          tag_name: ${{ github.ref }}
-          release_name: ${{ env.RELEASE_NAME }}
-          draft: false
-          prerelease: ${{ env.PRERELEASE }}
-          body: ${{ env.RELEASE_NOTE }}
-      - name: Upload Release Asset
-        id: upload-release-asset
-        uses: actions/upload-release-asset@v1
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-        with:
-          upload_url: ${{ steps.create_release.outputs.upload_url }}
-          asset_path: ./${{ env.RELEASE_FILENAME }}.zip
-          asset_name: ${{ env.RELEASE_FILENAME }}.zip
-          asset_content_type: application/zip
+        run: |
+          set -x
+          params=("-m" "$RELEASE_NAME" "-m" "$RELEASE_NOTE")
+          if [ "$PRERELEASE" = "true" ]; then
+            params+=("-p")
+          fi
+          for asset in ./*.zip; do
+            params+=("-a" "$asset")
+          done
+          hub release create "${params[@]}" v$VERSION

+ 2 - 1
gulpfile.js

@@ -57,7 +57,7 @@ async function readManifest() {
 /**
  * Versioning
  *
- * The version of extension is composed of `version` and `beta` fields in `package.json`, i.e.
+ * The version of extension is composed of `version` and `beta` fields in `package.json`.
  *
  * Note: prerelease is ignored and not recommended since both Chrome and Firefox do not support semver
  *
@@ -202,6 +202,7 @@ function logError(err) {
 const pack = gulp.parallel(manifest, createIcons, copyFiles, copyI18n);
 
 exports.clean = clean;
+exports.manifest = manifest;
 exports.dev = gulp.series(gulp.parallel(pack, jsDev), watch);
 exports.build = gulp.series(clean, gulp.parallel(pack, jsProd));
 exports.i18n = updateI18n;

+ 1 - 2
scripts/action-helper.js

@@ -9,10 +9,9 @@ core.exportVariable('RELEASE_NAME', [
   beta && 'BETA',
   `v${version}`,
 ].filter(Boolean).join(' '));
-core.exportVariable('RELEASE_FILENAME', [
+core.exportVariable('RELEASE_PREFIX', [
   'Violentmonkey',
   beta && 'beta',
-  `v${version}`,
 ].filter(Boolean).join('-'));
 core.exportVariable('PRERELEASE', !!beta);