Update CI

This commit is contained in:
MengYX 2020-11-06 22:40:23 +08:00
parent fbdad625c5
commit 60e2039e56
No known key found for this signature in database
GPG Key ID: E63F9C7303E8F604
2 changed files with 165 additions and 83 deletions

67
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,67 @@
name: Build
on:
push:
branches: [ master ]
paths:
- "**/*.js"
- "**/*.vue"
- "public/**/*"
- "package-lock.json"
- "package.json"
pull_request:
branches: [ master ]
types: [ opened, synchronize, reopened ]
paths:
- "**/*.js"
- "**/*.vue"
- "public/**/*"
- "package-lock.json"
- "package.json"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
build: [ legacy, modern ]
include:
- build: legacy
BUILD_ARGS:
- build: modern
BUILD_ARGS: "-- --modern"
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Get npm cache directory
id: npm-cache
run: echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-
- name: Install Dependencies
run: |
npm ci
npm run fix-compatibility
- name: Build
env:
GZIP: "--best"
run: |
npm run build ${{ matrix.BUILD_ARGS }}
tar -czvf dist.tar.gz -C ./dist .
- name: Publish artifact
uses: actions/upload-artifact@v2
with:
name: unlock-music-${{ matrix.build }}.tar.gz
path: ./dist.tar.gz

View File

@ -3,104 +3,119 @@ name: Release and GitHub Pages
on: on:
push: push:
tags: tags:
- "v*" - "v*"
jobs: jobs:
build: build:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Use Node.js 12.x - name: Use Node.js 14.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 12.x node-version: 14.x
- name: Install Dependencies - name: Get npm cache directory
run: | id: npm-cache
npm ci run: echo "::set-output name=dir::$(npm config get cache)"
npm run fix-compatibility - uses: actions/cache@v2
- name: Build Legacy with:
run: | path: ${{ steps.npm-cache.outputs.dir }}
npm run build key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
tar -czf legacy.tar.gz -C ./dist . restore-keys: ${{ runner.os }}-node-
zip -rJ9 legacy.zip ./dist
- name: Build Modern
run: |
npm run build -- --modern
tar -czf modern.tar.gz -C ./dist .
zip -rJ9 modern.zip ./dist
- run: sha256sum *.tar.gz *.zip > sha256sum.txt
- name: Deploy - name: Install Dependencies
uses: peaceiris/actions-gh-pages@v3 run: |
with: npm ci
github_token: ${{ secrets.GITHUB_TOKEN }} npm run fix-compatibility
publish_dir: ./dist
- name: Get current time - name: Build Legacy
id: date env:
run: echo "::set-output name=date::$(date +'%Y/%m/%d')" GZIP: "--best"
run: |
npm run build
tar -czf legacy.tar.gz -C ./dist .
zip -rJ9 legacy.zip ./dist
- name: Create a Release - name: Build Modern
id: create_release env:
uses: actions/create-release@v1 GZIP: "--best"
env: run: |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} npm run build -- --modern
with: tar -czf modern.tar.gz -C ./dist .
tag_name: ${{ github.ref }} zip -rJ9 modern.zip ./dist
release_name: "Build ${{ steps.date.outputs.date }}"
draft: true
- name: Upload Release Assets - legacy.tar.gz - name: Checksum
uses: actions/upload-release-asset@v1.0.2 run: sha256sum *.tar.gz *.zip > sha256sum.txt
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 - name: Deploy
uses: actions/upload-release-asset@v1.0.2 uses: peaceiris/actions-gh-pages@v3
env: with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
with: publish_dir: ./dist
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 - name: Get current time
uses: actions/upload-release-asset@v1.0.2 id: date
env: run: echo "::set-output name=date::$(date +'%Y/%m/%d')"
- name: Create a Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} tag_name: ${{ github.ref }}
asset_path: ./modern.tar.gz release_name: "Build ${{ steps.date.outputs.date }}"
asset_name: modern.tar.gz draft: true
asset_content_type: application/gzip
- name: Upload Release Assets - modern.zip - name: Upload Release Assets - legacy.tar.gz
uses: actions/upload-release-asset@v1.0.2 uses: actions/upload-release-asset@v1.0.2
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./modern.zip asset_path: ./legacy.tar.gz
asset_name: modern.zip asset_name: legacy.tar.gz
asset_content_type: application/zip asset_content_type: application/gzip
- name: Upload Release Assets - sha256sum.txt - name: Upload Release Assets - legacy.zip
uses: actions/upload-release-asset@v1.0.2 uses: actions/upload-release-asset@v1.0.2
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ steps.create_release.outputs.upload_url }} upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sha256sum.txt asset_path: ./legacy.zip
asset_name: sha256sum.txt asset_name: legacy.zip
asset_content_type: text/plain 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