Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
leojonathanoh committed Sep 12, 2021
2 parents a106d2a + f0af774 commit 1cd8ecb
Show file tree
Hide file tree
Showing 15 changed files with 567 additions and 221 deletions.
52 changes: 52 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release.
name-template: '$RESOLVED_VERSION 🌈'
tag-template: '$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- title: '🖊️ Refactors'
labels:
- 'refactor'
- title: '👗 Style'
labels:
- 'style'
- title: '📝 Documentation'
labels:
- 'docs'
- 'documentation'
- title: '🧰 Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
version-resolver:
major:
labels:
# - 'major'
- 'breaking'
minor:
labels:
# - 'minor'
- 'feature'
- 'enhancement'
- 'refactor'
patch:
labels:
# - 'patch'
- 'fix'
- 'bugfix'
- 'bug'
- 'style'
- 'docs'
- 'documentation'
default: patch
sort-by: title
template: |
## Changes
$CHANGES
207 changes: 188 additions & 19 deletions .github/workflows/ci-master-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ on:
push:
branches:
- master
- release # For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release.
pull_request:
branches:
- master

jobs:

build-4-1-4-ubuntu-16-04:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
env:
VARIANT_TAG: 4.1.4-ubuntu-16.04
# VARIANT_TAG_WITH_REF: 4.1.4-ubuntu-16.04-${GITHUB_REF}
VARIANT_BUILD_DIR: variants/4.1.4-ubuntu-16.04
steps:
- uses: actions/checkout@v1
- name: Checkout
uses: actions/checkout@v2

- name: Display system info (linux)
run: |
set -e
Expand All @@ -29,34 +32,200 @@ jobs:
pwd
docker info
docker version
- name: Login to docker registry
run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin
env:
DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
- name: Build and push image
# See: https://github.com/docker/build-push-action/blob/v2.6.1/docs/advanced/cache.md#github-cache
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Prepare
id: prep
env:
DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
run: |
set -e
# Get 'project-name' from 'namespace/project-name'
CI_PROJECT_NAME=$( echo "${GITHUB_REPOSITORY}" | rev | cut -d '/' -f 1 | rev )
# Get 'namespace' and 'project-name' from 'namespace/project-name'
# CI_PROJECT_NAMESPACE=$( echo "${{ github.repository }}" | cut -d '/' -f 1 )
# CI_PROJECT_NAME=$( echo "${{ github.repository }}" | cut -d '/' -f 2 )
# Get 'ref-name' from 'refs/heads/ref-name'
REF=$( echo "${GITHUB_REF}" | rev | cut -d '/' -f 1 | rev )
SHA_SHORT=$( echo "${GITHUB_SHA}" | cut -c1-7 )
# Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine'
# For Generate-DockerImageVariants: Generate the final tags. E.g. 'master-v1.0.0-alpine' and 'master-b29758a-v1.0.0-alpine'
VARIANT_TAG_WITH_REF="${REF}-${VARIANT_TAG}"
VARIANT_TAG_WITH_REF_AND_SHA_SHORT="${REF}-${SHA_SHORT}-${VARIANT_TAG}"
docker build \
-t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}" \
-t "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}" \
"${VARIANT_BUILD_DIR}"
docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF}"
docker push "${DOCKERHUB_REGISTRY_USER}/${CI_PROJECT_NAME}:${VARIANT_TAG_WITH_REF_AND_SHA_SHORT}"
# Set step output(s)
# echo "::set-output name=CI_PROJECT_NAMESPACE::$CI_PROJECT_NAMESPACE"
# echo "::set-output name=CI_PROJECT_NAME::$CI_PROJECT_NAME"
# echo "::set-output name=REF::$REF"
# echo "::set-output name=SHA_SHORT::$SHA_SHORT"
# echo "::set-output name=REF_AND_SHA_SHORT::$REF_AND_SHA_SHORT"
# For Generate-DockerImageVariants: Set step output(s)
echo "::set-output name=CONTEXT::$VARIANT_BUILD_DIR"
echo "::set-output name=VARIANT_TAG::$VARIANT_TAG"
echo "::set-output name=VARIANT_TAG_WITH_REF::$VARIANT_TAG_WITH_REF"
echo "::set-output name=VARIANT_TAG_WITH_REF_AND_SHA_SHORT::$VARIANT_TAG_WITH_REF_AND_SHA_SHORT"
- name: Login to docker registry
run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin
env:
DOCKERHUB_REGISTRY_USER: ${{ secrets.DOCKERHUB_REGISTRY_USER }}
DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}

- name: Build (PRs)
id: docker_build_pr
# Run only on pull requests
if: github.event_name == 'pull_request'
uses: docker/build-push-action@v2
with:
context: ${{ steps.prep.outputs.CONTEXT }}
platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x
push: false
tags: |
${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }}
${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Build and push (master)
id: docker_build_master
# Run only on master
if: github.ref == 'refs/heads/master'
uses: docker/build-push-action@v2
with:
context: ${{ steps.prep.outputs.CONTEXT }}
platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x
push: true
tags: |
${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }}
${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }}
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Build and push (release)
id: docker_build_release
# For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release.
# if: startsWith(github.ref, 'refs/tags/')
if: github.ref == 'refs/heads/release'
uses: docker/build-push-action@v2
with:
context: ${{ steps.prep.outputs.CONTEXT }}
platforms: linux/386,linux/amd64,linux/arm,linux/arm64,linux/s390x
push: true
tags: |
${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG }}
${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF }}
${{ github.repository }}:${{ steps.prep.outputs.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }}
${{ github.repository }}:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: List docker images
run: docker images

- name: Clean-up
run: docker logout
if: always()
if: always()

# For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release.
converge-master-and-release-branches:
needs: [build-4-1-4-ubuntu-16-04]
if: github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Merge release into master (fast-forward)
run: |
git checkout master
git merge release
git push origin master
# For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release.
resolve-release-tag:
runs-on: ubuntu-latest
outputs:
TAG: ${{ steps.resolve-release-tag.outputs.TAG }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Resolve release tag
id: resolve-release-tag
run: |
set +e
# E.g. 20210402
TODAYS_DATE=$( date -u '+%Y%m%d' )
# Is this the first tag for this date?
TODAYS_DATE_TAGS=$( git tag --list | grep "^$TODAYS_DATE" )
TAG=
if [ -z "$TODAYS_DATE_TAGS" ]; then
# E.g. 20210402.0.0
TAG="$TODAYS_DATE.0.0" # Send this to stdout
else
# E.g. if there are 20210402.0.0, 20210402.0.1, 20210402.0.2, this returns 2
VERSION_MINOR_LATEST=$( echo "$TODAYS_DATE_TAGS" | cut -d '.' -f 3 | sort -nr | head -n1 )
# Minor version
VERSION_MINOR=$( expr "$VERSION_MINOR_LATEST" + 1 )
# E.g. 20210402.0.3
TAG="$TODAYS_DATE.0.$VERSION_MINOR" # Send this to stdout
fi
echo "TODAYS_DATE: $TODAYS_DATE"
echo "TODAYS_DATE_TAGS: $TODAYS_DATE_TAGS"
echo "TAG: $TAG"
echo "::set-output name=TAG::$TAG"
- name: Print outputs
run: echo ${{ steps.resolve-release-tag.outputs.TAG }}

update-draft-release:
needs: [build-4-1-4-ubuntu-16-04, resolve-release-tag]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Print inputs
run: echo ${{ needs.resolve-release-tag.outputs.TAG }}
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: false
name: ${{ needs.resolve-release-tag.outputs.TAG }}
tag: ${{ needs.resolve-release-tag.outputs.TAG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-draft-release:
needs: [build-4-1-4-ubuntu-16-04, converge-master-and-release-branches, resolve-release-tag]
# For Generate-DockerImageVariants: For CalVer releases. Each push to 'release' branch is a time-based release.
# if: startsWith(github.ref, 'refs/tags/')
if: github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: true
name: ${{ needs.resolve-release-tag.outputs.TAG }}
tag: ${{ needs.resolve-release-tag.outputs.TAG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 0 additions & 63 deletions .github/workflows/ci-release.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Generate-DockerImageVariants",
"type": "process",
"command": "pwsh",
"args": [
"-c",
"Generate-DockerImageVariants ."
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Install DockerImageVariants module",
"type": "process",
"command": "pwsh",
"args": [
"-c",
"Install-Module -Name Generate-DockerImageVariants -Repository PSGallery -Scope CurrentUser -Force -Verbose"
],
"group": "build"
}
]
}
Loading

0 comments on commit 1cd8ecb

Please sign in to comment.