Add Release CICD and docker-compose #5
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: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build: | |
name: Build and Push Docker Image to Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/homedb:${{ github.sha }} | |
release: | |
name: Create GitHub Release | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Version | |
run: | | |
VERSION=$(grep -Po '(?<=version = ")[^"]*' pyproject.toml) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Delete existing release if it exists | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh release delete ${{ env.VERSION }} -y || echo "Release does not exist, continuing..." | |
- name: Create GitHub Release | |
id: create_release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
RELEASE_NOTES="Docker Hub: https://hub.docker.com/r/${{ secrets.DOCKER_USERNAME }}/homedb" | |
gh release create ${{ env.VERSION }} --title "HomeDB - v${{ env.VERSION }}" --notes "$RELEASE_NOTES" --generate-notes |