From 7396bf1c25123f434a0553bf6c6924eeb64888b1 Mon Sep 17 00:00:00 2001 From: Kamil Date: Fri, 22 Nov 2024 19:30:33 +0000 Subject: [PATCH] added github workflows --- .bumpversion.cfg | 9 +++++ .github/workflows/main.yml | 53 ++++++++++++++++++++++++++++++ .github/workflows/manual-build.yml | 40 ++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 .bumpversion.cfg create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/manual-build.yml diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..114fd39 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,9 @@ +[bumpversion] +current_version = 0.1.0 +commit = True +tag = True + +[bumpversion:file:version.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..6b09414 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,53 @@ +name: Build and Release on Main + +on: + push: + branches: + - main + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + # Checkout repository + - name: Checkout repository + uses: actions/checkout@v3 + + # Extract version from version.py + - name: Extract Version + id: extract_version + run: | + version=$(python3 -c "import version; print(version.__version__)") + echo "VERSION=$version" >> $GITHUB_ENV + + # Set up Docker + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Log in to GHCR + - name: Log in to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Build and push Docker image to GHCR with version tag + - name: Build and Push Docker Image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository}}:${{ env.VERSION }} + + # Create a release on GitHub + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ env.VERSION }} + name: Release ${{ env.VERSION }} + generate_release_notes: true + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/manual-build.yml b/.github/workflows/manual-build.yml new file mode 100644 index 0000000..cfbc3e2 --- /dev/null +++ b/.github/workflows/manual-build.yml @@ -0,0 +1,40 @@ +name: Manual Build for Dev or Feature Branches + +on: + workflow_dispatch: + inputs: + branch: + description: 'Branch to build the Docker image from' + required: true + default: 'dev' + +jobs: + manual-build: + runs-on: ubuntu-latest + + steps: + # Checkout the specified branch + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: ${{ github.event.inputs.branch }} + + # Set up Docker + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Log in to GHCR + - name: Log in to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Build and push Docker image to GHCR + - name: Build and Push Docker Image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/${{ github.repository }}:${{ github.sha }}