230 lines
6.9 KiB
YAML
230 lines
6.9 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/setup-node@v2.1.1
|
|
with:
|
|
node-version: 14
|
|
- uses: actions/cache@v2
|
|
with:
|
|
path: ~/.npm
|
|
key: client-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
- run: npm ci
|
|
env:
|
|
SKIP_BUILD: true
|
|
- run: npm run lint -- --no-fix
|
|
|
|
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:
|
|
- uses: actions/checkout@v2
|
|
- run: npm ci
|
|
env:
|
|
SKIP_BUILD: true
|
|
- name: Turnstyle
|
|
uses: softprops/turnstyle@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
- id: release
|
|
name: semantic-release
|
|
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:
|
|
- uses: actions/github-script@v3
|
|
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 })
|
|
buildx:
|
|
needs: release
|
|
if: needs.release.outputs.published == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
-
|
|
name: Prepare
|
|
id: prep
|
|
run: |
|
|
DOCKER_IMAGE=${{ github.event.repository.full_name }}
|
|
|
|
TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${{ needs.release.outputs.release-version }},${DOCKER_IMAGE}:v${{ needs.release.outputs.release-version-major }}"
|
|
|
|
echo ::set-output name=tags::${TAGS}
|
|
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
|
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
-
|
|
name: Set up QEMU
|
|
uses: docker/setup-qemu-action@master
|
|
with:
|
|
platforms: all
|
|
|
|
-
|
|
name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@master
|
|
with:
|
|
version: latest
|
|
|
|
-
|
|
name: Cache Docker layers
|
|
uses: actions/cache@v2
|
|
env:
|
|
cache-name: buildx
|
|
id: cache
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
${{ runner.os }}-${{ env.cache-name }}-
|
|
${{ runner.os }}-
|
|
|
|
-
|
|
name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
-
|
|
name: Build and push
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
context: .
|
|
file: ./Dockerfile
|
|
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
build-args: |
|
|
VERSION=${{ needs.release.outputs.release-version }}
|
|
BUILD_DATE=${{ steps.prep.outputs.build_date }}
|
|
REVISION=${{ github.sha }}
|
|
|
|
-
|
|
name: Check manifest
|
|
run: |
|
|
docker buildx imagetools inspect ${{ steps.prep.outputs.docker_image }}:${{ needs.release.outputs.release-version }}
|
|
|
|
|
|
buildx-web:
|
|
needs: release
|
|
if: needs.release.outputs.published == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
-
|
|
name: Prepare
|
|
id: prep
|
|
run: |
|
|
DOCKER_IMAGE=ttshivers/syncloungeweb
|
|
|
|
TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${{ needs.release.outputs.release-version }},${DOCKER_IMAGE}:v${{ needs.release.outputs.release-version-major }}"
|
|
|
|
echo ::set-output name=tags::${TAGS}
|
|
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
|
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
-
|
|
name: Set up QEMU
|
|
uses: docker/setup-qemu-action@master
|
|
with:
|
|
platforms: all
|
|
|
|
-
|
|
name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@master
|
|
with:
|
|
version: latest
|
|
|
|
-
|
|
name: Cache Docker layers
|
|
uses: actions/cache@v2
|
|
env:
|
|
cache-name: buildx-web
|
|
id: cache
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
${{ runner.os }}-${{ env.cache-name }}-
|
|
${{ runner.os }}-
|
|
|
|
-
|
|
name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
-
|
|
name: Build and push
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
push: true
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
context: .
|
|
file: ./Dockerfile.web
|
|
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
build-args: |
|
|
VERSION=${{ needs.release.outputs.release-version }}
|
|
BUILD_DATE=${{ steps.prep.outputs.build_date }}
|
|
REVISION=${{ github.sha }}
|
|
|
|
-
|
|
name: Check manifest
|
|
run: |
|
|
docker buildx imagetools inspect ${{ steps.prep.outputs.docker_image }}:${{ needs.release.outputs.release-version }}
|