Unverified Commit 4b493218 authored by Kevin Holmes's avatar Kevin Holmes Committed by GitHub
Browse files

ci: add docker image build to release workflow (#266)


* ci: add docker image build to release workflow

* better name for actions job

* remove ghcr.io due to 403-Forbidden issues

* remove qemu install/note

* ci: add define release version job

* small syntax fixes

* improved input error handling
Co-authored-by: default avatarmyishay <myishay@gmail.com>
parent 188107f0
No related merge requests found
Showing with 61 additions and 14 deletions
+61 -14
......@@ -7,8 +7,22 @@ on:
required: false
jobs:
define_version_job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: define_version
name: Define release version
run: |-
OUTPUT_VERSION=$(bash scripts/define_release_version.sh ${{ github.event.inputs.release_candidate_version }})
echo "detected version = $OUTPUT_VERSION"
echo ::set-output name=version::$(echo $OUTPUT_VERSION)
outputs:
version: ${{ steps.define_version.outputs.version }}
release:
runs-on: ubuntu-latest
needs: define_version_job
steps:
- name: Extract branch name
shell: bash
......@@ -41,7 +55,7 @@ jobs:
\"env\": {
\"global\": [
\"RELEASE_DATREE_PROD=true\",
\"RELEASE_CANDIDATE_VERSION=${{ github.event.inputs.release_candidate_version }}\"
\"RELEASE_VERSION=${{ needs.define_version_job.outputs.version }}\"
]
}
}
......@@ -58,3 +72,30 @@ jobs:
-H "Authorization: token ${TRAVIS_API_TOKEN}" \
-d "$BODY" \
"https://api.travis-ci.com/repo/${GH_ORGANIZATION_NAME}%2F${GH_REPOSITORY_NAME}/requests"
release-docker:
env:
REPO_NAME: datree
IMAGE_NAME: datree
name: Release container image to public registries
needs: [release, define_version_job]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: Log in to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push to registries
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:latest
${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ needs.define_version_job.outputs.version }}
cache-from: type=gha
cache-to: type=gha
#!/bin/bash
set -e
if test -z "$1"; then
latestRcTag=$(git tag --sort=-version:refname | grep "\-rc$" | head -n 1)
else
latestRcTag="$1"
fi
pattern="^[0-9]+\.[0-9]+\.[0-9]+\-rc$"
if [[ ! $latestRcTag =~ $pattern ]]; then
echo "release candidate does not match expected pattern"
exit 1
fi
release_tag=${latestRcTag%-rc}
echo $release_tag
#!/bin/bash
set -ex
if test -z "$RELEASE_CANDIDATE_VERSION"; then
latestRcTag=$(git tag --sort=-version:refname | grep "\-rc$" | head -n 1)
else
latestRcTag="$RELEASE_CANDIDATE_VERSION"
fi
release_tag=$RELEASE_VERSION
if test -z "$latestRcTag"; then
echo "couldn't find latestRcTag"
exit 1
fi
echo $latestRcTag
git checkout "$release_tag-rc"
git checkout $latestRcTag
release_tag=${latestRcTag%-rc}
git tag $release_tag -a -m "Generated tag from manual TravisCI for production build $TRAVIS_BUILD_NUMBER"
git push origin $release_tag # TODO: check if goreleaser pushes the tag itself (so no need to push here)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment