diff --git a/.github/workflows/mantis-cli-release.yml b/.github/workflows/mantis-cli-release.yml index 26b2c5cd..c4319f60 100644 --- a/.github/workflows/mantis-cli-release.yml +++ b/.github/workflows/mantis-cli-release.yml @@ -10,18 +10,39 @@ 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 }} @@ -29,14 +50,14 @@ jobs: - 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 }}