Skip to content

Commit

Permalink
Update github CI
Browse files Browse the repository at this point in the history
  • Loading branch information
essembeh committed Jan 12, 2024
1 parent 2c66bfc commit 64756d5
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 39 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/helm.yml

This file was deleted.

36 changes: 29 additions & 7 deletions .github/workflows/build.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ env:

jobs:
python-test:
name: Build and test App
name: Build and test Python application
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: "3.10"
- name: Install poetry
run: pip install poetry
- name: Build app
run: poetry build
- name: Test app
run: |
poetry install
poetry run coverage run -m pytest
poetry run pytest --cov=yourss
poetry run coverage report
poetry run coverage xml
Expand All @@ -32,21 +32,43 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}

- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/essembeh/yourss

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
push: true

helm-release:
name: Update Helm repository
if: github.ref == 'refs/heads/main'
needs: docker-build
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@v3
- name: Run chart-releaser
uses: helm/[email protected]
with:
skip_existing: true
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
38 changes: 38 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -eu -o pipefail

[ "$1" = "patch" ] || [ "$1" = "minor" ] || [ "$1" = "major" ]

# create new version with poetry
VERSION=$(poetry version "$1" -s)

# update charts
yq e '.version = strenv(VERSION)' -i charts/yourss/Chart.yaml
yq e '.appVersion = strenv(VERSION)' -i charts/yourss/Chart.yaml

# add updated files to staging
git add pyproject.toml charts/yourss/Chart.yaml
git --no-pager diff --staged

echo ""
echo ""
echo ""

# ask confirmation before commit
read -p "💡 Commit changes and create tag? [y/n] " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
git commit --message "🔖 New release: $VERSION"
git tag "$VERSION"

# ask confirmation before push to origin
read -p "💡 Push to origin? [y/n] " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
git push
git push --tags
fi
else
# revert changes
echo "Reverting changes ..."
git reset HEAD pyproject.toml charts/yourss/Chart.yaml
git checkout pyproject.toml charts/yourss/Chart.yaml
fi

0 comments on commit 64756d5

Please sign in to comment.