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

Release versions check #2

Merged
merged 4 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
43 changes: 0 additions & 43 deletions .github/workflows/deploy-api-acr.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .github/workflows/deploy-api-dh.yml

This file was deleted.

82 changes: 49 additions & 33 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,63 @@
---

name: Publish Docker image
name: Deploy API image to Docker Hub

on:
release:
# Publish on release
types:
- published
- released
- prereleased

jobs:
docker_build:
deploy_to_docker_hub:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check that we can build docker container image
run: docker build -t rctab:latest .

push_to_registry:
needs: docker_build
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Login to DockerHub
- name: Checkout repository
uses: actions/checkout@v2

- name: Check that tag and package versions match
run: |
PYPROJECT_VERSION=$(sed -n '3p' pyproject.toml | sed "s/version = //")
GITHUB_VERSION=${{ github.event.release.tag_name }}
if [[ "$PYPROJECT_VERSION" != "\"$GITHUB_VERSION\"" ]]
then
echo "pyproject.toml version $PYPROJECT_VERSION doesn't match GitHub version \"$GITHUB_VERSION\""
exit 1
fi

- name: Get release tag
id: current_release
run: |
CURRENT_RELEASE=${{ github.event.release.tag_name }}
echo "CURRENT_RELEASE=${CURRENT_RELEASE}" >> $GITHUB_ENV
IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_RELEASE"
MAJOR_VERSION_NUMBER="${VERSION_PARTS[0]}"
echo "MAJOR_VERSION_NUMBER=${MAJOR_VERSION_NUMBER}" >> $GITHUB_ENV
echo "The current release is $CURRENT_RELEASE"
echo "The current major version number is $MAJOR_VERSION_NUMBER"

- name: Set pre-release suffix
if: ${{ github.event.release.prerelease }}
run: |
echo "TAG_SUFFIX='prelease'" >> $GITHUB_ENV

- name: Set release suffix
if: ${{ !github.event.release.prerelease }}
run: |
echo "TAG_SUFFIX='latest'" >> $GITHUB_ENV

- name: Login to Docker Hub
id: docker_login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Push to Docker Hub
# uses: docker/build-push-action@v4
# with:
# context: .
# file: Dockerfile
# tags: turingrc/rctab
# push: true

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Build and Push current release and latest tag to Docker Hub
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
tags: |
turingrc/rctab-api:${{ env.CURRENT_RELEASE }}
turingrc/rctab-api:${{ env.MAJOR_VERSION_NUMBER }}.${{ env.TAG_SUFFIX }}
push: true
86 changes: 0 additions & 86 deletions .github/workflows/dev-test-deploy.yml

This file was deleted.

Loading