Browse Source

chore: add github actions. (#340)

* chore: add github actions.

* chore: add github actions.

* chore: add github actions.

* chore: add github actions.

* chore: add github actions.

* chore: add github actions.

* chore: add github actions.

* chore: remove travis ci.

* doc: update README.md
pull/341/head
Ryan Wang 3 years ago committed by GitHub
parent
commit
d673c9d62e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 91
      .github/workflows/main.yml
  2. 27
      .travis.yml
  3. 2
      README.md
  4. 6
      scripts/zip_dist.sh

91
.github/workflows/main.yml

@ -1,30 +1,83 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node name: Halo Admin CI
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on: on:
push:
branches: [ master ]
pull_request: pull_request:
branches: [ master ] paths:
- '**'
- '!**.md'
push:
branches:
- '**'
paths:
- '**'
- '!**.md'
release:
types:
- created
jobs: jobs:
build: check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
node-version: [10.x, 12.x, 14.x] node-version: [10.x, 12.x, 14.x, 15.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run lint
github-release:
runs-on: ubuntu-latest
needs: check
if: github.event_name == 'release'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js 14
uses: actions/setup-node@v1 uses: actions/setup-node@v2
with: with:
node-version: ${{ matrix.node-version }} node-version: '14'
- run: npm install - run: npm install
- run: npm run build --if-present - name: Build for release
- run: npm test run: npm run build
- name: Compress dist directory
run: |
PACKAGE_VERSION=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' package.json)
ARTIFACT_NAME=halo-admin-${PACKAGE_VERSION}.zip
ARTIFACT_PATHNAME=dist/${ARTIFACT_NAME}
echo "Halo admin version $PACKAGE_VERSION"
echo "Artifact name: ${ARTIFACT_NAME}"
echo "Artifact pathname: ${ARTIFACT_PATHNAME}"
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV
echo "RELEASE_ID=${{ github.event.release.id }}" >> $GITHUB_ENV
zip -r $ARTIFACT_PATHNAME dist
- name: Upload a Release Asset
uses: actions/github-script@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
const releaseId = process.env.RELEASE_ID
const artifactPathName = process.env.ARTIFACT_PATHNAME
const artifactName = process.env.ARTIFACT_NAME
console.log('Releasing', releaseId, artifactPathName, artifactName)
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: releaseId,
name: artifactName,
data: await fs.readFile(artifactPathName)
});

27
.travis.yml

@ -1,27 +0,0 @@
language: node_js
node_js: stable
jobs:
include:
- stage: build
script:
- npm run build
- scripts/zip_dist.sh
- ls -la dist
deploy:
provider: releases
api_key: $GITHUB_OAUTH_TOKEN
file_glob: true
file: dist/*.zip
skip_cleanup: true
on:
tags: true
stages:
- build
branches:
only:
- master
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
notifications:
webhooks: https://fathomless-fjord-24024.herokuapp.com/notify

2
README.md

@ -7,7 +7,7 @@
<a href="https://www.jsdelivr.com/package/npm/halo-admin"><img alt="npm release" src="https://data.jsdelivr.com/v1/package/npm/halo-admin/badge"/></a> <a href="https://www.jsdelivr.com/package/npm/halo-admin"><img alt="npm release" src="https://data.jsdelivr.com/v1/package/npm/halo-admin/badge"/></a>
<a href="https://github.com/halo-dev/halo-admin/releases"><img alt="GitHub All Releases" src="https://img.shields.io/github/downloads/halo-dev/halo-admin/total.svg?style=flat-square"></a> <a href="https://github.com/halo-dev/halo-admin/releases"><img alt="GitHub All Releases" src="https://img.shields.io/github/downloads/halo-dev/halo-admin/total.svg?style=flat-square"></a>
<a href="https://github.com/halo-dev/halo-admin/commits"><img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/halo-dev/halo-admin.svg?style=flat-square"></a> <a href="https://github.com/halo-dev/halo-admin/commits"><img alt="GitHub last commit" src="https://img.shields.io/github/last-commit/halo-dev/halo-admin.svg?style=flat-square"></a>
<a href="https://travis-ci.org/halo-dev/halo-admin"><img alt="Travis CI" src="https://img.shields.io/travis/halo-dev/halo-admin.svg?style=flat-square"/></a> <a href="https://github.com/halo-dev/halo-admin/actions"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/halo-dev/halo-admin/Halo%20Admin%20CI?style=flat-square"/></a>
</p> </p>
------------------------------ ------------------------------

6
scripts/zip_dist.sh

@ -1,6 +0,0 @@
#!/bin/bash
PACKAGE_VERSION=$(sed -nE 's/^\s*"version": "(.*?)",$/\1/p' package.json)
echo "Halo admin version $PACKAGE_VERSION"
zip -r dist/halo-admin-$PACKAGE_VERSION.zip dist
export PACKAGE_VERSION
Loading…
Cancel
Save