Merge pull request #2 from ELIXIR-NO/fix/ca_cert_conf #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Bump Version and Publish Docker Image | |
on: | |
push: | |
branches: | |
- main # Runs on pushes to the main branch | |
workflow_dispatch: | |
permissions: | |
packages: write | |
contents: write | |
jobs: | |
bump_version: | |
if: "!contains(github.event.head_commit.message, '[docs]')" | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.extract_version.outputs.version }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Poetry | |
run: | | |
pip install poetry | |
poetry install | |
- name: Install bump2version | |
run: | | |
pip install bump2version | |
- name: Determine version bump type | |
id: version_type | |
run: | | |
if [[ "${{ github.event.head_commit.message }}" =~ "major" ]]; then | |
echo "bump_type=major" >> $GITHUB_ENV | |
elif [[ "${{ github.event.head_commit.message }}" =~ "minor" ]]; then | |
echo "bump_type=minor" >> $GITHUB_ENV | |
else | |
echo "bump_type=patch" >> $GITHUB_ENV | |
fi | |
- name: Bump Version | |
id: bumpversion | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
bump2version ${{ env.bump_type }} | |
git push --follow-tags | |
- name: Get New Version from pyproject.toml | |
id: extract_version | |
run: | | |
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml) | |
echo "Bumped to: $VERSION" | |
echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
build_and_push: | |
if: "!contains(github.event.head_commit.message, '[docs]')" | |
runs-on: ubuntu-latest | |
needs: bump_version # Wait for the version bump job to finish | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Set Repository Name | |
id: repo_name | |
run: | | |
REPO_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') | |
echo "repo_name=$REPO_NAME" >> $GITHUB_ENV | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
tags: | | |
ghcr.io/${{ env.repo_name }}:${{ needs.bump_version.outputs.version }} | |
ghcr.io/${{ env.repo_name }}:latest | |
push: 'true' |