2020-08-24 03:09:06 +00:00
|
|
|
name: release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
jobs:
|
2020-09-30 20:58:27 +00:00
|
|
|
release-test:
|
2020-08-24 03:09:06 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Checkout
|
2020-11-05 07:34:32 +00:00
|
|
|
uses: actions/checkout@v2.3.4
|
2020-09-10 20:26:14 +00:00
|
|
|
|
|
|
|
- name: Setup Node.js
|
2020-12-17 06:28:55 +00:00
|
|
|
uses: actions/setup-node@v2.1.4
|
2020-08-24 03:09:06 +00:00
|
|
|
with:
|
2020-10-24 03:13:08 +00:00
|
|
|
node-version: 15
|
2020-09-10 20:26:14 +00:00
|
|
|
|
|
|
|
- name: Cache Node.js modules
|
2020-09-10 21:52:56 +00:00
|
|
|
id: cache
|
2020-11-09 07:22:40 +00:00
|
|
|
uses: actions/cache@v2.1.3
|
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 21:52:56 +00:00
|
|
|
- name: Cache hit
|
|
|
|
run: echo ${{ steps.cache.outputs.cache-hit }}
|
|
|
|
|
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
|
|
|
|
2020-09-30 20:58:27 +00:00
|
|
|
release-semantic:
|
|
|
|
needs: release-test
|
2020-08-24 03:09:06 +00:00
|
|
|
|
|
|
|
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-10-01 20:23:01 +00:00
|
|
|
- name: Setup Node.js
|
2020-12-17 06:28:55 +00:00
|
|
|
uses: actions/setup-node@v2.1.4
|
2020-10-01 20:23:01 +00:00
|
|
|
with:
|
2020-10-24 03:13:08 +00:00
|
|
|
node-version: 15
|
2020-10-01 20:23:01 +00:00
|
|
|
|
2020-10-13 23:42:50 +00:00
|
|
|
- name: Turnstyle
|
2020-11-09 08:44:08 +00:00
|
|
|
uses: softprops/turnstyle@v1
|
2020-10-13 23:42:50 +00:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Checkout
|
2020-11-05 07:34:32 +00:00
|
|
|
uses: actions/checkout@v2.3.4
|
2020-10-13 23:42:50 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Cache Node.js modules
|
2020-09-10 21:52:56 +00:00
|
|
|
id: cache
|
2020-11-09 07:22:40 +00:00
|
|
|
uses: actions/cache@v2.1.3
|
2020-09-10 20:26:14 +00:00
|
|
|
with:
|
|
|
|
path: ~/.npm
|
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node-
|
|
|
|
|
2020-09-10 21:52:56 +00:00
|
|
|
- name: Cache hit
|
|
|
|
run: echo ${{ steps.cache.outputs.cache-hit }}
|
|
|
|
|
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: Semantic release
|
|
|
|
id: release
|
2021-01-22 06:21:45 +00:00
|
|
|
uses: ahmadnassri/action-semantic-release@v1.7.7
|
2020-08-24 03:09:06 +00:00
|
|
|
env:
|
|
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
npm_config_unsafe_perm: true
|
|
|
|
|
2020-09-30 20:58:27 +00:00
|
|
|
release-alias:
|
|
|
|
needs: release-semantic
|
|
|
|
if: needs.release-semantic.outputs.published == 'true'
|
2020-08-24 03:09:06 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2020-09-30 20:58:27 +00:00
|
|
|
tag:
|
|
|
|
- v${{ needs.release-semantic.outputs.release-version-major }}
|
|
|
|
- v${{ needs.release-semantic.outputs.release-version-major }}.${{ needs.release-semantic.outputs.release-version-minor }}
|
2020-08-24 03:09:06 +00:00
|
|
|
|
|
|
|
steps:
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Recreate tag
|
2020-11-19 03:47:22 +00:00
|
|
|
uses: actions/github-script@v3.1.0
|
2020-08-24 03:09:06 +00:00
|
|
|
with:
|
|
|
|
script: |
|
2020-09-30 20:58:27 +00:00
|
|
|
const tag = 'tags/${{ matrix.tag }}';
|
2020-08-24 03:09:06 +00:00
|
|
|
const repo = {
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo
|
2020-09-30 20:58:27 +00:00
|
|
|
};
|
|
|
|
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
|
|
|
|
2020-09-30 20:58:27 +00:00
|
|
|
release-docker:
|
|
|
|
needs: release-semantic
|
|
|
|
if: needs.release-semantic.outputs.published == 'true'
|
2020-08-24 03:09:06 +00:00
|
|
|
runs-on: ubuntu-latest
|
2020-09-10 20:26:14 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
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-11-05 07:34:32 +00:00
|
|
|
uses: actions/checkout@v2.3.4
|
2020-09-08 19:26:21 +00:00
|
|
|
|
2020-10-11 20:23:45 +00:00
|
|
|
- name: Repo metadata
|
|
|
|
id: repo
|
2020-11-19 03:47:22 +00:00
|
|
|
uses: actions/github-script@v3.1.0
|
2020-10-11 20:23:45 +00:00
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const repo = await github.repos.get(context.repo)
|
|
|
|
return repo.data
|
|
|
|
|
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-10-11 20:23:45 +00:00
|
|
|
echo ::set-output name=created::$(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
|
2020-10-02 17:01:49 +00:00
|
|
|
uses: docker/setup-qemu-action@v1.0.1
|
2020-09-08 19:26:21 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Set up Docker Buildx
|
2020-09-08 19:26:21 +00:00
|
|
|
id: buildx
|
2021-01-06 06:54:49 +00:00
|
|
|
uses: docker/setup-buildx-action@v1.1.1
|
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-28 06:17:17 +00:00
|
|
|
- name: Get platforms
|
2020-11-19 03:47:22 +00:00
|
|
|
uses: actions/github-script@v3.1.0
|
2020-09-28 06:17:17 +00:00
|
|
|
id: platforms
|
|
|
|
env:
|
|
|
|
DOCKER_CLI_EXPERIMENTAL: enabled
|
|
|
|
with:
|
|
|
|
result-encoding: string
|
|
|
|
script: |
|
|
|
|
const script = require(`${process.env.GITHUB_WORKSPACE}/.github/getDockerPlatforms.js`)
|
|
|
|
return script("${{ matrix.dockerfile }}", "${{ steps.buildx.outputs.platforms }}");
|
|
|
|
|
|
|
|
- name: Platforms
|
|
|
|
run: echo ${{ steps.platforms.outputs.result }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Cache Docker layers
|
2020-11-09 07:22:40 +00:00
|
|
|
uses: actions/cache@v2.1.3
|
2020-08-26 00:02:54 +00:00
|
|
|
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 21:52:56 +00:00
|
|
|
- name: Cache hit
|
|
|
|
run: echo ${{ steps.cache.outputs.cache-hit }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Login to DockerHub
|
2020-12-21 07:32:14 +00:00
|
|
|
uses: docker/login-action@v1.8.0
|
2020-09-08 19:26:21 +00:00
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Build and push
|
|
|
|
id: docker-build
|
2021-01-11 07:10:51 +00:00
|
|
|
uses: docker/build-push-action@v2.2.2
|
2020-09-08 19:26:21 +00:00
|
|
|
with:
|
|
|
|
push: true
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
context: .
|
2020-09-10 20:26:14 +00:00
|
|
|
file: ./${{ matrix.dockerfile}}
|
2020-09-28 06:17:17 +00:00
|
|
|
platforms: ${{ steps.platforms.outputs.result }}
|
2020-09-10 20:26:14 +00:00
|
|
|
tags: |
|
|
|
|
${{ matrix.docker-image }}:latest
|
2020-09-30 20:58:27 +00:00
|
|
|
${{ matrix.docker-image }}:${{ needs.release-semantic.outputs.release-version }}
|
|
|
|
${{ matrix.docker-image }}:${{ needs.release-semantic.outputs.release-version-major }}.${{ needs.release-semantic.outputs.release-version-minor }}
|
|
|
|
${{ matrix.docker-image }}:${{ needs.release-semantic.outputs.release-version-major }}
|
2020-10-11 20:23:45 +00:00
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.title=${{ fromJson(steps.repo.outputs.result).name }}
|
|
|
|
org.opencontainers.image.description=${{ fromJson(steps.repo.outputs.result).description }}
|
|
|
|
org.opencontainers.image.url=${{ fromJson(steps.repo.outputs.result).html_url }}
|
|
|
|
org.opencontainers.image.source=${{ fromJson(steps.repo.outputs.result).clone_url }}
|
|
|
|
org.opencontainers.image.version=${{ needs.release-semantic.outputs.release-version }}
|
|
|
|
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
|
|
|
|
org.opencontainers.image.revision=${{ github.sha }}
|
|
|
|
org.opencontainers.image.licenses=${{ fromJson(steps.repo.outputs.result).license.spdx_id }}
|
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: |
|
2020-09-30 20:58:27 +00:00
|
|
|
VERSION=${{ needs.release-semantic.outputs.release-version }}
|
2020-09-08 19:26:21 +00:00
|
|
|
|
2020-11-19 04:17:35 +00:00
|
|
|
# - name: Update repo description
|
|
|
|
# uses: peter-evans/dockerhub-description@v2.4.1
|
|
|
|
# with:
|
|
|
|
# username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
# password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
# repository: ${{ matrix.docker-image }}
|
2020-09-10 20:38:26 +00:00
|
|
|
|
2020-09-10 20:26:14 +00:00
|
|
|
- name: Inspect
|
2020-08-26 00:02:54 +00:00
|
|
|
run: |
|
2020-09-30 20:58:27 +00:00
|
|
|
docker buildx imagetools inspect ${{ matrix.docker-image }}:${{ needs.release-semantic.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: Dump context
|
|
|
|
if: always()
|
2020-10-19 01:18:45 +00:00
|
|
|
uses: crazy-max/ghaction-dump-context@v1.1.0
|