Update module gopkg.in/evanphx/json-patch.v4 to v5 (#5) #8
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: Release and Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
name: Release and Publish | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up Helm | |
uses: azure/[email protected] | |
- name: Calculate next version | |
id: version | |
run: | | |
# Get the latest tag | |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
echo "Latest tag: $latest_tag" | |
# Extract current version | |
current_version=${latest_tag#v} | |
echo "Current version: $current_version" | |
# Default to patch bump unless the commit message specifies "feat" or "BREAKING CHANGE" | |
bump="patch" | |
if git log -1 --pretty=%B | grep -iq "feat"; then | |
bump="minor" | |
elif git log -1 --pretty=%B | grep -iq "BREAKING CHANGE"; then | |
bump="major" | |
fi | |
# Calculate the new version | |
IFS='.' read -r major minor patch <<< "$current_version" | |
case $bump in | |
patch) patch=$((patch + 1)) ;; | |
minor) minor=$((minor + 1)); patch=0 ;; | |
major) major=$((major + 1)); minor=0; patch=0 ;; | |
esac | |
new_version="$major.$minor.$patch" | |
echo "New version: $new_version" | |
echo "new_version=$new_version" >> $GITHUB_ENV | |
- name: Configure git | |
run: | | |
git config --local user.name "GitHub Actions" | |
git config --local user.email "[email protected]" | |
- name: Update Helm Chart version | |
run: | | |
sed -i "s/^version:.*/version: ${{ env.new_version }}/" ./charts/homer-operator/Chart.yaml | |
- name: Run helm-docs | |
uses: losisin/helm-docs-github-action@v1 | |
- name: Commit and push Helm chart changes | |
run: | | |
git add ./charts/homer-operator/ | |
git commit -m "[skip actions] Update Helm chart docs and version to ${{ env.new_version }}" | |
git push origin main | |
- name: Tag the release | |
run: | | |
git tag -a ${{ env.new_version }} -m "Release ${{ env.new_version }}" | |
git push origin ${{ env.new_version }} | |
- name: Log in to GitHub Container Registry for Docker | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Log in to GitHub Container Registry for Helm | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/homer-operator:${{ env.new_version }} | |
ghcr.io/${{ github.repository_owner }}/homer-operator:${{ github.sha }} | |
ghcr.io/${{ github.repository_owner }}/homer-operator:latest | |
- name: Package and push Helm chart | |
run: | | |
helm package ./charts/homer-operator -d ./artifacts | |
CHART_NAME=$(ls ./artifacts | grep .tgz) | |
helm push ./artifacts/$CHART_NAME oci://ghcr.io/${{ github.repository_owner }}/homer-operator |