From f8a1ec137cf1ae8e979c827333c3ee1ecd907b8f Mon Sep 17 00:00:00 2001 From: MengYX Date: Thu, 28 May 2020 02:24:32 +0800 Subject: [PATCH] Update and rename deploy.yml to release.yml --- .github/workflows/deploy.yml | 35 ------------- .github/workflows/release.yml | 99 +++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 35 deletions(-) delete mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 4200163..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,35 +0,0 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - -name: GitHub Pages CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-18.04 - - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js 12.x - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - run: npm ci - - run: npm run fix-compatibility - - run: npm run build -- --modern - - - name: deploy - uses: peaceiris/actions-gh-pages@v3 - with: - deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} - publish_dir: ./dist - - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..50ddbe9 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,99 @@ +name: Release and GitHub Pages + +on: + push: + tags: + - "v*" + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js 12.x + uses: actions/setup-node@v1 + with: + node-version: 12.x + + - name: Install Dependencies + run: | + npm ci + npm run fix-compatibility + - name: Build Legacy + run: | + npm run build + tar -czf legacy.tar.gz -C ./dist . + zip -J9 legacy.zip ./dist + - name: Build Modern + run: | + npm run build -- --modern + tar -czf modern.tar.gz -C ./dist . + zip -J9 modern.zip ./dist + - run: sha256sum *.tar.gz *.zip > sha256sum.txt + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist + + - name: Create a Release + id: create_release + uses: actions/create-release@v1 + with: + release_name: "Build $(date %Y/%m/%d)" + draft: true + + - name: Upload Release Assets - legacy.tar.gz + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./legacy.tar.gz + asset_name: legacy.tar.gz + asset_content_type: application/gzip + + - name: Upload Release Assets - legacy.zip + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./legacy.zip + asset_name: legacy.zip + asset_content_type: application/zip + + - name: Upload Release Assets - modern.tar.gz + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./modern.tar.gz + asset_name: modern.tar.gz + asset_content_type: application/gzip + + - name: Upload Release Assets - modern.zip + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./modern.zip + asset_name: modern.zip + asset_content_type: application/zip + + - name: Upload Release Assets - sha256sum.txt + uses: actions/upload-release-asset@v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./sha256sum.txt + asset_name: sha256sum.txt + asset_content_type: text/plain +