Skip to content

Commit

Permalink
Merge pull request #150 from mimiro-io/versioning
Browse files Browse the repository at this point in the history
versioning improvements
  • Loading branch information
rompetroll authored Aug 10, 2022
2 parents dbd7518 + c05f1e1 commit c305972
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 7 deletions.
85 changes: 80 additions & 5 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,35 @@ jobs:

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Docker Buildx (enable caching)
uses: docker/setup-buildx-action@v1


- name: install semver tool
run: pip3 install semver

- name: validate release tag
run: |
if [ ${{ github.event_name }} == 'release' ]
then
echo "Validate that release tag is valid semver"
pysemver check $(echo $GITHUB_REF | cut -d / -f 3)
fi
- name: get next version
id: semver-tag
run: |
git fetch --all --tags
DESCRIBE=$( git describe --always --tags --long --first-parent )
VERSION=$(echo $DESCRIBE | cut -d "-" -f 1)
NEXT=$( pysemver bump patch $VERSION )
echo "::set-output name=tag::$NEXT"
- name: "Calculated unstable tag"
run: echo "base tag next unstable version... ${{ steps.semver-tag.outputs.tag }}"

- name: Set Image Tag
id: image_tag
run: |
Expand All @@ -35,7 +60,7 @@ jobs:
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:$(echo $GITHUB_REF | cut -d / -f 3)-$(uname -m)
else
echo "Setting Unstable Image"
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:v-$(cat VERSION.txt)$GITHUB_RUN_NUMBER-unstable-$(uname -m)
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:${{ steps.semver-tag.outputs.tag }}-$GITHUB_RUN_NUMBER-unstable-$(uname -m)
fi
# Login to Docker registry except on PR
Expand Down Expand Up @@ -90,10 +115,35 @@ jobs:

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Docker Buildx (enable caching)
uses: docker/setup-buildx-action@v1

- name: install semver tool
run: pip3 install semver

- name: validate release tag
run: |
if [ ${{ github.event_name }} == 'release' ]
then
echo "Validate that release tag is valid semver"
/home/ec2-user/.local/bin/pysemver check $(echo $GITHUB_REF | cut -d / -f 3)
fi
- name: get next version
id: semver-tag
run: |
git fetch --all --tags
DESCRIBE=$( git describe --always --tags --long --first-parent )
VERSION=$(echo $DESCRIBE | cut -d "-" -f 1)
NEXT=$( /home/ec2-user/.local/bin/pysemver bump patch $VERSION )
echo "::set-output name=tag::$NEXT"
- name: "Calculated unstable tag"
run: echo "base tag next unstable version... ${{ steps.semver-tag.outputs.tag }}"

- name: Set Image Tag
id: image_tag
run: |
Expand All @@ -103,7 +153,7 @@ jobs:
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:$(echo $GITHUB_REF | cut -d / -f 3)-$(uname -m)
else
echo "Setting Unstable Image"
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:v-$(cat VERSION.txt)$GITHUB_RUN_NUMBER-unstable-$(uname -m)
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:${{ steps.semver-tag.outputs.tag }}-$GITHUB_RUN_NUMBER-unstable-$(uname -m)
fi
# Login to Docker registry except on PR
Expand Down Expand Up @@ -164,6 +214,31 @@ jobs:

- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: install semver tool
run: pip3 install semver

- name: validate release tag
run: |
if [ ${{ github.event_name }} == 'release' ]
then
echo "Validate that release tag is valid semver"
pysemver check $(echo $GITHUB_REF | cut -d / -f 3)
fi
- name: get next version
id: semver-tag
run: |
git fetch --all --tags
DESCRIBE=$( git describe --always --tags --long --first-parent )
VERSION=$(echo $DESCRIBE | cut -d "-" -f 1)
NEXT=$( pysemver bump patch $VERSION )
echo "::set-output name=tag::$NEXT"
- name: "Calculated unstable tag"
run: echo "base tag next unstable version... ${{ steps.semver-tag.outputs.tag }}"

- name: Login to DockerHub
id: docker_login
Expand All @@ -181,8 +256,8 @@ jobs:
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:$(echo $GITHUB_REF | cut -d / -f 3)
else
echo "Setting Unstable Image"
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:v-$(cat VERSION.txt)$GITHUB_RUN_NUMBER-unstable
fi
echo ::set-output name=image_tag:: ${{ env.DOCKERHUB_REPOSITORY }}:${{ steps.semver-tag.outputs.tag }}-$GITHUB_RUN_NUMBER-unstable
fi
- name: Show Tag
run: echo ${{ steps.image_tag.outputs.image_tag }}
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-extldflags=-static" -tags jemal
RUN go test ./... -v

FROM alpine:latest

RUN apk update
RUN apk add --upgrade rsync
RUN apk --no-cache add ca-certificates rsync

WORKDIR /root/
Expand Down
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.
1.0.

0 comments on commit c305972

Please sign in to comment.