Browse Source

Update CI

20230320
MengYX 4 years ago
parent
commit
60e2039e56
No known key found for this signature in database GPG Key ID: E63F9C7303E8F604
  1. 67
      .github/workflows/build.yml
  2. 199
      .github/workflows/release.yml

67
.github/workflows/build.yml

@ -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

199
.github/workflows/release.yml

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

Loading…
Cancel
Save