chore(deps): bump mikepenz/release-changelog-builder-action from 5 to 6 #7
This file contains hidden or 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 | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*.*.*' | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version to release (without v prefix, e.g. 1.2.3)' | ||
| required: true | ||
| type: string | ||
| env: | ||
| RELEASE_VERSION: ${{ github.event_name == 'workflow_dispatch' && format('v{0}', github.event.inputs.version) || github.ref_name }} | ||
| IMG: ghcr.io/openvirtualcluster/openvirtualcluster-operator:${{ github.event_name == 'workflow_dispatch' && format('v{0}', github.event.inputs.version) || github.ref_name }} | ||
| jobs: | ||
| validate-version: | ||
| if: github.event_name == 'workflow_dispatch' | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| is_valid: ${{ steps.validate.outputs.is_valid }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Validate version | ||
| id: validate | ||
| run: | | ||
| INPUT_VERSION="${{ github.event.inputs.version }}" | ||
| # Check if version is a valid semver (X.Y.Z format) | ||
| if ! [[ $INPUT_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Error: Version must be in format X.Y.Z (e.g. 1.2.3)" | ||
| echo "is_valid=false" >> $GITHUB_OUTPUT | ||
| exit 1 | ||
| fi | ||
| # Get all existing tags | ||
| git fetch --tags | ||
| # Check if tag already exists | ||
| if git tag | grep -q "^v$INPUT_VERSION$"; then | ||
| echo "Error: Version v$INPUT_VERSION already exists" | ||
| echo "is_valid=false" >> $GITHUB_OUTPUT | ||
| exit 1 | ||
| fi | ||
| # Find latest version | ||
| LATEST_TAG=$(git tag -l "v*.*.*" | sort -V | tail -n 1) | ||
| if [ -z "$LATEST_TAG" ]; then | ||
| echo "No previous versions found. This will be the first release." | ||
| echo "is_valid=true" >> $GITHUB_OUTPUT | ||
| exit 0 | ||
| fi | ||
| LATEST_VERSION=${LATEST_TAG#v} | ||
| # Split versions into components | ||
| IFS='.' read -r LATEST_MAJOR LATEST_MINOR LATEST_PATCH <<< "$LATEST_VERSION" | ||
| IFS='.' read -r INPUT_MAJOR INPUT_MINOR INPUT_PATCH <<< "$INPUT_VERSION" | ||
| # Convert to integers for comparison | ||
| LATEST_MAJOR=$((10#$LATEST_MAJOR)) | ||
| LATEST_MINOR=$((10#$LATEST_MINOR)) | ||
| LATEST_PATCH=$((10#$LATEST_PATCH)) | ||
| INPUT_MAJOR=$((10#$INPUT_MAJOR)) | ||
| INPUT_MINOR=$((10#$INPUT_MINOR)) | ||
| INPUT_PATCH=$((10#$INPUT_PATCH)) | ||
| # Validate version is newer | ||
| if [ $INPUT_MAJOR -gt $LATEST_MAJOR ]; then | ||
| # Major version bump is valid | ||
| echo "Valid major version bump: $LATEST_VERSION -> $INPUT_VERSION" | ||
| echo "is_valid=true" >> $GITHUB_OUTPUT | ||
| elif [ $INPUT_MAJOR -eq $LATEST_MAJOR ] && [ $INPUT_MINOR -gt $LATEST_MINOR ]; then | ||
| # Minor version bump is valid | ||
| echo "Valid minor version bump: $LATEST_VERSION -> $INPUT_VERSION" | ||
| echo "is_valid=true" >> $GITHUB_OUTPUT | ||
| elif [ $INPUT_MAJOR -eq $LATEST_MAJOR ] && [ $INPUT_MINOR -eq $LATEST_MINOR ] && [ $INPUT_PATCH -gt $LATEST_PATCH ]; then | ||
| # Patch version bump is valid | ||
| echo "Valid patch version bump: $LATEST_VERSION -> $INPUT_VERSION" | ||
| echo "is_valid=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "Error: Version $INPUT_VERSION is not newer than the latest version $LATEST_VERSION" | ||
| echo "New version must increment major, minor, or patch number" | ||
| echo "is_valid=false" >> $GITHUB_OUTPUT | ||
| exit 1 | ||
| fi | ||
| build-and-push: | ||
| needs: [validate-version] | ||
| if: github.event_name != 'workflow_dispatch' || needs.validate-version.outputs.is_valid == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
| - 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 version | ||
| id: get_version | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | ||
| echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Build and push multi-platform image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| platforms: linux/amd64,linux/arm64 | ||
| push: true | ||
| tags: ${{ env.IMG }} | ||
| labels: | | ||
| org.opencontainers.image.title=openvirtualcluster-operator | ||
| org.opencontainers.image.description=OpenVirtualCluster Operator | ||
| org.opencontainers.image.version=${{ steps.get_version.outputs.VERSION }} | ||
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | ||
| org.opencontainers.image.revision=${{ github.sha }} | ||
| release: | ||
| needs: [build-and-push] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Create directory for changelog config | ||
| run: mkdir -p .github/workflows/changelog_builder | ||
| - name: Create changelog config | ||
| run: | | ||
| cat > .github/workflows/changelog_builder/config.json << EOF | ||
| { | ||
| "categories": [ | ||
| { | ||
| "title": "## 🚀 Features", | ||
| "labels": ["feature", "enhancement"] | ||
| }, | ||
| { | ||
| "title": "## 🐛 Fixes", | ||
| "labels": ["fix", "bugfix", "bug"] | ||
| }, | ||
| { | ||
| "title": "## 📝 Documentation", | ||
| "labels": ["documentation"] | ||
| }, | ||
| { | ||
| "title": "## 🧰 Maintenance", | ||
| "labels": ["chore", "maintenance"] | ||
| } | ||
| ], | ||
| "ignore_labels": ["ignore"], | ||
| "sort": "ASC", | ||
| "template": "${{CHANGELOG}}" | ||
| } | ||
| EOF | ||
| - name: "Build Changelog" | ||
| id: github_release | ||
| uses: mikepenz/release-changelog-builder-action@v6 | ||
| with: | ||
| configuration: ".github/workflows/changelog_builder/config.json" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Create Release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| tag_name: ${{ env.RELEASE_VERSION }} | ||
| name: ${{ env.RELEASE_VERSION }} | ||
| body: ${{ steps.github_release.outputs.changelog }} | ||
| generate_release_notes: true | ||
| build-installer: | ||
| needs: [build-and-push] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: 'go.mod' | ||
| - name: Build installer | ||
| run: | | ||
| make build-installer | ||
| env: | ||
| IMG: ${{ env.IMG }} | ||
| - name: Upload installer artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: installer | ||
| path: dist/install.yaml | ||
| - name: Upload installer to release | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| tag_name: ${{ env.RELEASE_VERSION }} | ||
| files: dist/install.yaml | ||