Skip to content

Commit

Permalink
Modified workflow to automatically bump release versions when merging…
Browse files Browse the repository at this point in the history
… to main
  • Loading branch information
Ncoder2 committed Jun 2, 2024
1 parent c73eda0 commit d1c725d
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/mantis-cli-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,54 @@ env:

jobs:
build-and-push-image:
if: github.event_name == 'workflow_dispatch'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write

actions: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install dependencies
run: poetry install

- name: Bump version
id: bump_version
run: poetry run bump2version patch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Push version bump commit and tag
run: |
git push origin main --tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.bump_version.outputs.new_version }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit d1c725d

Please sign in to comment.