Skip to content

Commit

Permalink
Improvement/workflow (#26)
Browse files Browse the repository at this point in the history
* Add semver package to dev requirements.

* Add docker inspect output to test job.

* Add proper parsing of semver.

Disregards pre-release and build metadata parts.

* Capture pre-release and metabuild data in a tag.
  • Loading branch information
felddy authored Oct 13, 2020
1 parent 22f58a0 commit 4508d69
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
id: prep
run: |
VERSION=noop
SEMVER="^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$"
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
Expand All @@ -102,17 +103,22 @@ jobs:
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${IMAGE_NAME}:${VERSION}"
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
MINOR=${VERSION%.*}
MAJOR=${MINOR%.*}
TAGS="$TAGS,${IMAGE_NAME}:${MINOR},${IMAGE_NAME}:${MAJOR},${IMAGE_NAME}:latest"
elif [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${IMAGE_NAME}:sha-${GITHUB_SHA::8}"
if [[ $VERSION =~ $SEMVER ]]; then
VERSION_NO_V=${VERSION#v}
MAJOR="${BASH_REMATCH[1]}"
MINOR="${BASH_REMATCH[2]}"
PATCH="${BASH_REMATCH[3]}"
TAGS="${IMAGE_NAME}:${VERSION_NO_V//+/_},${IMAGE_NAME}:${MAJOR}.${MINOR}.${PATCH},${IMAGE_NAME}:${MAJOR}.${MINOR},${IMAGE_NAME}:${MAJOR},${IMAGE_NAME}:latest"
else
TAGS="${IMAGE_NAME}:${VERSION}"
fi
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="${TAGS},${IMAGE_NAME}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=source_version::$(./bump_version.sh show)
echo ::set-output name=tags::${TAGS}
echo tags=${TAGS}
- name: Setup debug session remote shell
uses: mxschmitt/action-tmate@v3
if: github.event.inputs.remote-shell == 'true'
Expand Down Expand Up @@ -205,8 +211,10 @@ jobs:
with:
name: dist
path: dist
- name: Load docker image
- name: Load Docker image
run: docker load < dist/image.tar.gz
- name: Inspect Docker image
run: docker image inspect ${IMAGE_NAME}
- name: Prepare data volume mount
run: |
chmod a+rwx data
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--requirement requirements-test.txt
semver

0 comments on commit 4508d69

Please sign in to comment.