Skip to content

πŸ”€ Merge pull request #13 from jyje/develop #16

πŸ”€ Merge pull request #13 from jyje/develop

πŸ”€ Merge pull request #13 from jyje/develop #16

Workflow file for this run

name: release
on:
push:
branches:
- main
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tag name
run: |
cat requirements.txt | grep -oP '==\K[0-9]+\.[0-9]+\.[0-9]+' > tag.txt
echo "image_version=v$(cat tag.txt)" >> $GITHUB_ENV
TAG_NAME="${{ env.image_version }}"
if ! [[ "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then
echo "Tag $TAG_NAME does not meet the required format 'vX.Y.Z'."
exit 1
fi
- name: Publish as GitHub Package
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ env.image_version }}
- name: Set tag and push in Github
run: |
# Set Git identity
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Check if the tag already exists
TAG_EXISTS=$(git tag --list ${{ env.image_version }})
if [ -n "$TAG_EXISTS" ]; then
echo "Tag ${{ env.image_version }} already exists."
exit 0
fi
# Create and push the new tag
git tag ${{ env.image_version }}
git push origin ${{ env.image_version }}
- name: Create Release
if: success()
uses: ncipollo/release-action@v1
with:
tag: ${{ env.image_version }}
name: Release ${{ env.image_version }}
token: ${{ secrets.GITHUB_TOKEN }}