This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
Merge pull request #198 from AirGrid/release/v0.0.0-dev.43 #516
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "[Edgekit] Build, Test and *Publish" | |
on: | |
pull_request: | |
branches: [ develop ] | |
push: | |
branches: | |
- master | |
- develop | |
release: | |
types: [ published ] | |
jobs: | |
build-and-test: | |
name: Build & Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- uses: microsoft/playwright-github-action@v1 | |
- name: Use Node v12 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 12 | |
- name: Build | |
run: npm ci | |
- name: Test | |
run: npm test | |
build-release-and-publish: | |
name: Build, Release & Publish | |
if: ${{ github.event_name == 'push' && endsWith(github.ref, '/master') }} | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Get Edgekit NPM version | |
run: | | |
EDGEKIT_NPM_VERSION=$(node -p "require('./package.json').version") | |
EDGEKIT_VERSION="v$EDGEKIT_NPM_VERSION" | |
if git rev-parse "$EDGEKIT_VERSION"; then | |
IS_NEW_EDGEKIT_VERSION=false | |
else | |
IS_NEW_EDGEKIT_VERSION=true | |
fi | |
echo "EDGEKIT_VERSION=$EDGEKIT_VERSION" >> $GITHUB_ENV | |
echo "IS_NEW_EDGEKIT_VERSION=$IS_NEW_EDGEKIT_VERSION" >> $GITHUB_ENV | |
- name: Check if new Edgekit version | |
run: ([ "$IS_NEW_EDGEKIT_VERSION" = true ] || exit 1) | |
- name: Use Node v12 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 12 | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
run: npm ci | |
- name: Compile code | |
run: npm run build | |
- name: Create UMD bundle | |
run: npm run bundle | |
- name: Create Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
with: | |
tag_name: ${{ env.EDGEKIT_VERSION }} | |
release_name: Release ${{ env.EDGEKIT_VERSION }} | |
- run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: 12 | |
registry-url: 'https://npm.pkg.github.com' | |
# Publish to GitHub Packages | |
- run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |