2020-08-24 03:09:06 +00:00
|
|
|
name: release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Setup Node.js
|
|
|
|
uses: actions/setup-node@v2.1.1
|
2020-08-24 03:09:06 +00:00
|
|
|
with:
|
|
|
|
node-version: 14
|
2020-09-10 20:26:14 +00:00
|
|
|
|
|
|
|
- name: Cache Node.js modules
|
|
|
|
uses: actions/cache@v2
|
2020-08-24 03:09:06 +00:00
|
|
|
with:
|
|
|
|
path: ~/.npm
|
2020-09-10 20:26:14 +00:00
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node-
|
2020-08-24 03:09:06 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: npm ci
|
2020-08-31 22:55:14 +00:00
|
|
|
env:
|
|
|
|
SKIP_BUILD: true
|
2020-09-10 20:26:14 +00:00
|
|
|
|
|
|
|
- name: Lint
|
|
|
|
run: npm run lint -- --no-fix
|
2020-08-24 03:09:06 +00:00
|
|
|
|
|
|
|
release:
|
|
|
|
needs: test
|
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
outputs:
|
|
|
|
published: ${{ steps.release.outputs.published }}
|
|
|
|
release-version: ${{ steps.release.outputs.release-version }}
|
|
|
|
release-version-major: ${{ steps.release.outputs.release-version-major }}
|
|
|
|
release-version-minor: ${{ steps.release.outputs.release-version-minor }}
|
|
|
|
|
|
|
|
steps:
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Cache Node.js modules
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/.npm
|
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node-
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: npm ci
|
2020-08-31 22:55:14 +00:00
|
|
|
env:
|
|
|
|
SKIP_BUILD: true
|
2020-09-10 20:26:14 +00:00
|
|
|
|
2020-09-08 19:30:10 +00:00
|
|
|
- name: Turnstyle
|
|
|
|
uses: softprops/turnstyle@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2020-09-10 20:26:14 +00:00
|
|
|
|
|
|
|
- name: Semantic release
|
|
|
|
id: release
|
2020-08-24 03:09:06 +00:00
|
|
|
uses: ahmadnassri/action-semantic-release@v1
|
|
|
|
env:
|
|
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
npm_config_unsafe_perm: true
|
|
|
|
|
|
|
|
alias:
|
|
|
|
needs: release
|
|
|
|
if: needs.release.outputs.published == 'true'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
alias:
|
|
|
|
- version: v${{ needs.release.outputs.release-version-major }}
|
|
|
|
- version: v${{ needs.release.outputs.release-version-major }}.${{ needs.release.outputs.release-version-minor }}
|
|
|
|
|
|
|
|
steps:
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Recreate tag
|
|
|
|
uses: actions/github-script@v3
|
2020-08-24 03:09:06 +00:00
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const tag = 'tags/${{ matrix.alias.version }}'
|
|
|
|
const repo = {
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo
|
|
|
|
}
|
|
|
|
await github.git.deleteRef({ ...repo, ref: tag }).catch(() => {})
|
|
|
|
await github.git.createRef({ ...repo, ref: `refs/${tag}` , sha: process.env.GITHUB_SHA })
|
2020-09-10 20:26:14 +00:00
|
|
|
|
|
|
|
docker:
|
2020-08-24 03:09:06 +00:00
|
|
|
needs: release
|
|
|
|
if: needs.release.outputs.published == 'true'
|
|
|
|
runs-on: ubuntu-latest
|
2020-09-10 20:26:14 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
dockerfile:
|
|
|
|
- Dockerfile
|
|
|
|
- Dockerfile.web
|
|
|
|
include:
|
|
|
|
- dockerfile: Dockerfile
|
|
|
|
docker-image: ${{ github.event.repository.full_name }}
|
|
|
|
- dockerfile: Dockerfile.web
|
|
|
|
docker-image: ${{ github.event.repository.full_name }}web
|
|
|
|
|
2020-08-24 03:09:06 +00:00
|
|
|
steps:
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Checkout
|
2020-08-24 03:09:06 +00:00
|
|
|
uses: actions/checkout@v2
|
2020-09-08 19:26:21 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Prepare
|
2020-09-08 19:26:21 +00:00
|
|
|
id: prep
|
2020-08-24 03:09:06 +00:00
|
|
|
run: |
|
2020-09-10 20:26:14 +00:00
|
|
|
echo ::set-output name=build-date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
2020-09-08 19:26:21 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
2020-09-08 19:26:21 +00:00
|
|
|
with:
|
|
|
|
platforms: all
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Set up Docker Buildx
|
2020-09-08 19:26:21 +00:00
|
|
|
id: buildx
|
2020-09-10 20:26:14 +00:00
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-09-08 19:26:21 +00:00
|
|
|
with:
|
|
|
|
version: latest
|
|
|
|
|
2020-09-10 20:50:29 +00:00
|
|
|
- name: Available platforms
|
|
|
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Cache Docker layers
|
2020-08-26 00:02:54 +00:00
|
|
|
uses: actions/cache@v2
|
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
2020-09-10 20:26:14 +00:00
|
|
|
key: ${{ runner.os }}-docker-${{ matrix.dockerfile }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
|
2020-08-26 00:02:54 +00:00
|
|
|
restore-keys: |
|
2020-09-10 20:26:14 +00:00
|
|
|
${{ runner.os }}-docker-${{ matrix.dockerfile }}-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
${{ runner.os }}-docker-${{ matrix.dockerfile }}-
|
|
|
|
${{ runner.os }}-docker-
|
2020-09-08 19:26:21 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Login to DockerHub
|
2020-09-08 19:26:21 +00:00
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Build and push
|
|
|
|
id: docker-build
|
2020-09-08 19:26:21 +00:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
push: true
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
context: .
|
2020-09-10 20:26:14 +00:00
|
|
|
file: ./${{ matrix.dockerfile}}
|
2020-09-10 21:35:31 +00:00
|
|
|
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
|
2020-09-10 20:26:14 +00:00
|
|
|
tags: |
|
|
|
|
${{ matrix.docker-image }}:latest
|
|
|
|
${{ matrix.docker-image }}:${{ needs.release.outputs.release-version }}
|
|
|
|
${{ matrix.docker-image }}:v${{ needs.release.outputs.release-version-major }}
|
2020-09-08 19:26:21 +00:00
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
2020-09-10 17:28:27 +00:00
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
|
2020-09-08 19:26:21 +00:00
|
|
|
build-args: |
|
|
|
|
VERSION=${{ needs.release.outputs.release-version }}
|
2020-09-10 20:26:14 +00:00
|
|
|
BUILD_DATE=${{ steps.prep.outputs.build-date }}
|
2020-09-08 19:26:21 +00:00
|
|
|
REVISION=${{ github.sha }}
|
|
|
|
|
2020-09-10 20:38:26 +00:00
|
|
|
- name: Update repo description
|
|
|
|
uses: peter-evans/dockerhub-description@v2
|
|
|
|
env:
|
|
|
|
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
DOCKERHUB_REPOSITORY: ${{ matrix.docker-image }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Inspect
|
2020-08-26 00:02:54 +00:00
|
|
|
run: |
|
2020-09-10 20:26:14 +00:00
|
|
|
docker buildx imagetools inspect ${{ matrix.docker-image }}:${{ needs.release.outputs.release-version }}
|
2020-08-24 03:09:06 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Image digest
|
|
|
|
run: echo ${{ steps.docker-build.outputs.digest }}
|
2020-09-08 19:26:21 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Cache hit
|
|
|
|
run: echo ${{ steps.cache.outputs.cache-hit }}
|
2020-09-08 19:26:21 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Dump context
|
|
|
|
if: always()
|
|
|
|
uses: crazy-max/ghaction-dump-context@v1
|