2020-04-06 04:44:28 +00:00
|
|
|
name: Release
|
|
|
|
on: push
|
|
|
|
|
|
|
|
env:
|
2020-09-03 07:19:52 +00:00
|
|
|
GITHUB_TOKEN: ${{ secrets.CR_PAT }}
|
|
|
|
REGISTRY: ghcr.io
|
2020-04-06 04:44:28 +00:00
|
|
|
NODE_VERSION: '12'
|
2020-10-21 08:00:49 +00:00
|
|
|
GO_VERSION: '1.15'
|
2020-04-06 04:44:28 +00:00
|
|
|
|
|
|
|
jobs:
|
2020-11-17 08:33:07 +00:00
|
|
|
container:
|
2020-05-13 12:41:43 +00:00
|
|
|
runs-on: ubuntu-18.04
|
|
|
|
steps:
|
|
|
|
- name: Source checkout
|
|
|
|
uses: actions/checkout@v2
|
2020-11-17 08:33:07 +00:00
|
|
|
- name: Set output
|
|
|
|
id: branch
|
|
|
|
run: echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}
|
|
|
|
- name: Check output
|
|
|
|
run: echo ${{ steps.branch.outputs.short_ref }}
|
|
|
|
- name: Generate Short SHA Container Tag
|
|
|
|
id: vars
|
|
|
|
run: echo "::set-output name=sha_short::SHA-$(git rev-parse --short HEAD)"
|
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
2020-04-06 04:44:28 +00:00
|
|
|
with:
|
2020-11-17 08:33:07 +00:00
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
2020-04-06 04:44:28 +00:00
|
|
|
with:
|
|
|
|
username: ${{ github.actor }}
|
2020-09-03 07:19:52 +00:00
|
|
|
password: ${{ secrets.CR_PAT }}
|
2020-04-06 04:44:28 +00:00
|
|
|
registry: ${{ env.REGISTRY }}
|
2020-11-17 08:33:07 +00:00
|
|
|
- uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
file: ./build/dockerfile
|
|
|
|
platforms: linux/amd64
|
|
|
|
tags: ${{ env.REGISTRY }}/${{ github.repository }}:${{ steps.vars.outputs.sha_short }},${{ env.REGISTRY }}/${{ github.repository }}:${{ steps.branch.outputs.short_ref }}
|
|
|
|
push: true
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
|
|
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache
|
2020-04-06 04:44:28 +00:00
|
|
|
|
2020-04-07 12:45:59 +00:00
|
|
|
release:
|
2020-04-06 04:44:28 +00:00
|
|
|
runs-on: ubuntu-18.04
|
2020-11-17 08:33:07 +00:00
|
|
|
needs: [container]
|
2020-04-06 07:44:32 +00:00
|
|
|
env:
|
|
|
|
DOCKER_USERNAME: ${{ github.actor }}
|
2020-09-03 07:19:52 +00:00
|
|
|
DOCKER_PASSWORD: ${{ secrets.CR_PAT }}
|
2020-04-06 04:44:28 +00:00
|
|
|
steps:
|
|
|
|
- name: Source checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Generate Short SHA Container Tag
|
|
|
|
id: vars
|
|
|
|
run: echo "::set-output name=sha_short::SHA-$(git rev-parse --short HEAD)"
|
|
|
|
- name: Docker Login
|
|
|
|
run: docker login $REGISTRY -u $GITHUB_ACTOR -p $GITHUB_TOKEN
|
|
|
|
- name: Docker Pull short-sha
|
2020-09-03 07:19:52 +00:00
|
|
|
run: docker pull $REGISTRY/$GITHUB_REPOSITORY:${{ steps.vars.outputs.sha_short }}
|
2020-04-07 12:45:59 +00:00
|
|
|
- name: Semantic Release
|
2020-11-17 11:00:46 +00:00
|
|
|
id: semantic
|
2020-04-07 12:45:59 +00:00
|
|
|
uses: cycjimmy/semantic-release-action@v2
|
|
|
|
with:
|
2020-05-14 05:38:58 +00:00
|
|
|
dry_run: false
|
2020-04-07 12:45:59 +00:00
|
|
|
semantic_version: 17.0.4
|
2020-11-17 11:00:46 +00:00
|
|
|
- name: Do something when a new release published
|
|
|
|
if: steps.semantic.outputs.new_release_published == 'true'
|
|
|
|
run: |
|
|
|
|
echo ${{ steps.semantic.outputs.new_release_version }}
|
|
|
|
echo ${{ steps.semantic.outputs.new_release_major_version }}
|
|
|
|
echo ${{ steps.semantic.outputs.new_release_minor_version }}
|
|
|
|
echo ${{ steps.semantic.outputs.new_release_patch_version }}
|
2020-04-16 11:46:43 +00:00
|
|
|
- name: Docker Tag Version
|
2020-11-17 11:00:46 +00:00
|
|
|
run: docker tag $REGISTRY/$GITHUB_REPOSITORY:${{ steps.vars.outputs.sha_short }} $REGISTRY/$GITHUB_REPOSITORY:${{ steps.semantic.outputs.new_release_version }}
|
|
|
|
if: steps.semantic.outputs.new_release_published == 'true'
|
2020-04-16 11:46:43 +00:00
|
|
|
- name: Docker Tag Latest
|
2020-09-03 07:19:52 +00:00
|
|
|
run: docker tag $REGISTRY/$GITHUB_REPOSITORY:${{ steps.vars.outputs.sha_short }} $REGISTRY/$GITHUB_REPOSITORY:latest
|
2020-11-17 11:00:46 +00:00
|
|
|
if: steps.semantic.outputs.new_release_published == 'true'
|
2020-04-16 11:46:43 +00:00
|
|
|
- name: Docker Push Version
|
2020-11-17 11:00:46 +00:00
|
|
|
run: docker push $REGISTRY/$GITHUB_REPOSITORY:${{ steps.semantic.outputs.new_release_version }}
|
|
|
|
if: steps.semantic.outputs.new_release_published == 'true'
|
2020-04-16 11:46:43 +00:00
|
|
|
- name: Docker Push Latest
|
2020-09-03 07:19:52 +00:00
|
|
|
run: docker push $REGISTRY/$GITHUB_REPOSITORY:latest
|
2020-11-17 11:00:46 +00:00
|
|
|
if: steps.semantic.outputs.new_release_published == 'true'
|