Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add publishing docker image by gradle in release workflow #159

Merged
merged 4 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,22 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DRY_RUN: true

- name: "3. Determine docker tags"
run: echo ::set-env name=DOCKER_TAGS::$(echo latest, ${{ steps.bump_dry.outputs.tag }})
- name: "3. Login to docker hub"
run: docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_TOKEN
env:
DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: "3-1. Determine docker tags for hotfix"
if: contains(github.event.head_commit.message, '#hotfix')
run: echo ::set-env name=DOCKER_TAGS::$(echo ${{ steps.bump_dry.outputs.tag }})
#check build.gradle file for explanation of next steps
- name: "4. Publish image with tag corresponding to current version"
run: |
./gradlew dockerPushVersion -P version=${{ steps.bump_dry.outputs.tag }}

- name: "5. Publish image with tag 'latest' if not hotfix"
if: ${{ !contains(github.event.head_commit.message, '#hotfix') }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens in case of #patch in commit message?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually also - what happens in case of hotfix itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe versioning logic should be documented somewhere (not for this pr) as it looks like it is not easy to deduce, at least for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens in case of #patch in commit message?

There was not any specific behaviour for #patch commit before my changes as far as I can see

Copy link
Contributor Author

@xfiderek xfiderek Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually also - what happens in case of hotfix itself?

In hotfix we skip publishing docker image with tag 'latest', since hotfix (according to my conversation with @endrjuskr ) refers to changes in one of previous versions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely something we have to concretely specify somewhere. Because the two latest hotfixes changed the latest release..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hotfixe is something that applies to older version that we still support. For instance v1 and v2. In our cases it was more like patch or minor, so that is why we released latest.

run: |
./gradlew dockerPushLatest

- name: "4. Build and publish docker to docker hub"
uses: elgohr/Publish-Docker-Github-Action@2.14
with:
name: unit8/darts
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
tags: "${{ env.DOCKER_TAGS }}"
cache: true
buildoptions: "--compress -q"

deploy-docs:
runs-on: ubuntu-latest
Expand Down
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ task build {
// docker & docker run
docker {
name "unit8/darts"
tags version, "latest"

// ./gradlew dockerPushVersion will push image with tag ${version}
// ${version} is property passed from command line during workflow
tag "version", "unit8/darts:${version}"

// ./gradlew dockerPushLatest will push image with tag 'latest'
tag "latest", "unit8/darts:latest"

dockerfile file("${project.rootDir}/Dockerfile")
// needed files for docker and to build library
files "README.md", "setup.py", "setup.cfg"
Expand Down