Skip to content

Workflow file for this run

name: "Create release"
#on:
# push:
# tags:
# - "*"
on: push
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l -e -o pipefail {0}
env:
IMAGE_NAME: npg-irods-python
REPOSITORY_OWNER: ${{ github.repository_owner }}
PYTHON_VERSION: "3.10"
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Fetch Tags"
# Workaround for https://github.com/actions/checkout/issues/290
run: git fetch --tags --force
- name: "Set up Python"
uses: actions/setup-python@v3
with:
python-version: ${{ env.PYTHON_VERSION }}
architecture: "x64"
- name: "Install Dependencies"
run: |
pip install --upgrade pip
pip install build
- name: "Build Package"
run: python -m build
- name: "Get release variables"
run: |
echo 'RELEASE_VERSION='$(git describe --always --tags --dirty) >> $GITHUB_ENV
echo 'MASTER_SHA='$(git rev-parse origin/master) >> $GITHUB_ENV
echo 'GIT_URL='$(git remote get-url origin) >> $GITHUB_ENV
echo 'GIT_COMMIT='$(git log --pretty=format:'%H' -n 1) >> $GITHUB_ENV
- name: "Create Release"
uses: ncipollo/release-action@v1.12.0
with:
name: ${{ env.RELEASE_VERSION }}
prerelease: ${{ !(github.sha == env.MASTER_SHA) }}
artifacts: "dist/*.tar.gz"
removeArtifacts: true
artifactErrorsFailBuild: true
generateReleaseNotes: true
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v2
with:
install: true
- name: "Login to Docker registry"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build Docker image"
run: |
docker build \
--file Dockerfile \
--platform linux/amd64 \
--progress plain \
--load \
--label "uk.ac.sanger.repository=$GIT_URL" \
--label "uk.ac.sanger.commit=$GIT_COMMIT" \
--tag "ghcr.io/$REPOSITORY_OWNER/$IMAGE_NAME:$RELEASE_VERSION" \
--tag "ghcr.io/$REPOSITORY_OWNER/$IMAGE_NAME:latest" \
.
- name: "Push Docker image"
run: |
docker images
echo pushing "ghcr.io/$REPOSITORY_OWNER/$IMAGE_NAME:$RELEASE_VERSION"
docker push "ghcr.io/$REPOSITORY_OWNER/$IMAGE_NAME:$RELEASE_VERSION"
docker push "ghcr.io/$REPOSITORY_OWNER/$IMAGE_NAME:latest"