Build image #107
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
| --- | |
| # ba0fde3d-bee7-4307-b97b-17d0d20aff50 | |
| name: Build image | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - 'main' | |
| paths-ignore: | |
| - '**/README.md' | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| set-env: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| LATEST_TAG: ${{ steps.set.outputs.LATEST_TAG }} | |
| REGISTRY: ${{ steps.set.outputs.REGISTRY }} | |
| REGISTRY_USER: ${{ steps.set.outputs.REGISTRY_USER }} | |
| PLATFORMS: ${{ steps.set.outputs.PLATFORMS }} | |
| IMAGE_PATH: ${{ steps.set.outputs.IMAGE_PATH }} | |
| IMAGE_NAME: ${{ steps.set.outputs.IMAGE_NAME }} | |
| IMAGE_REF: ${{ steps.set.outputs.IMAGE_REF }} | |
| VARIANTS: ${{ steps.set.outputs.VARIANTS }} | |
| MATRIX: ${{ steps.set.outputs.MATRIX }} | |
| IS_SIGNED: ${{ steps.set.outputs.IS_SIGNED }} | |
| steps: | |
| - name: Set environment variables | |
| id: set | |
| run: | | |
| # Pick a latest tag based on the event type | |
| if [[ "${{ github.ref }}" != "refs/heads/${{ github.event.repository.default_branch }}" ]]; then | |
| echo "LATEST_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "LATEST_TAG=latest" >> $GITHUB_OUTPUT | |
| fi | |
| REGISTRY=quay.io | |
| REGISTRY_USER="almalinuxorg+airibarr_bot" | |
| IMAGE_PATH="almalinuxorg" | |
| IMAGE_NAME=${{ github.event.repository.name }} | |
| PLATFORMS="amd64" | |
| VARIANTS="gnome,kde" | |
| echo "REGISTRY=${REGISTRY}" >> $GITHUB_OUTPUT | |
| echo "REGISTRY_USER=${REGISTRY_USER}" >> $GITHUB_OUTPUT | |
| echo "IMAGE_PATH=${IMAGE_PATH}" >> $GITHUB_OUTPUT | |
| echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
| echo "IMAGE_REF=${REGISTRY}/${IMAGE_PATH}/${IMAGE_NAME}" >> $GITHUB_OUTPUT | |
| echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_OUTPUT | |
| echo "VARIANTS=${VARIANTS}" >> $GITHUB_OUTPUT | |
| echo "MATRIX={\"variant\": $(echo $VARIANTS | jq -cR 'split(",")')}" >> $GITHUB_OUTPUT | |
| # This is a workaround so that the expansion of secrets.SIGNING_SECRET doesn't break the if statement | |
| SECRET=$(cat <<EOF | |
| ${{ secrets.SIGNING_SECRET }} | |
| EOF | |
| ) | |
| if [ -z "${SECRET}" ]; then | |
| echo "IS_SIGNED=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "IS_SIGNED=true" >> $GITHUB_OUTPUT | |
| fi | |
| build-test-promote: | |
| name: Build, Test, Promote | |
| needs: set-env | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{fromJson(needs.set-env.outputs.MATRIX)}} | |
| uses: ./.github/workflows/reusable-build.yml | |
| with: | |
| variant: ${{ matrix.variant }} | |
| containerfile: Dockerfile | |
| image_name: "${{ needs.set-env.outputs.IMAGE_NAME }}-${{ matrix.variant }}" | |
| previous_image: "${{ needs.set-env.outputs.IMAGE_REF }}-${{ matrix.variant }}:latest" | |
| update_origin_ref: "${{ needs.set-env.outputs.IMAGE_REF }}-${{ matrix.variant }}:${{ needs.set-env.outputs.LATEST_TAG }}" | |
| latest_tag: ${{ needs.set-env.outputs.LATEST_TAG }} | |
| update_is_signed: ${{ needs.set-env.outputs.IS_SIGNED == 'true' }} | |
| config_file: ./iso.toml | |
| platforms: ${{ needs.set-env.outputs.PLATFORMS }} | |
| image_path: ${{ needs.set-env.outputs.IMAGE_PATH }} | |
| registry: ${{ needs.set-env.outputs.REGISTRY }} | |
| registry_user: ${{ needs.set-env.outputs.REGISTRY_USER }} | |
| secrets: | |
| REGISTRY_TOKEN: ${{ secrets.QUAY_PASSWORD }} | |
| SIGNING_SECRET: ${{ secrets.SIGNING_SECRET }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| create-release: | |
| name: Create Release | |
| needs: [set-env, build-test-promote] | |
| if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Fetch Changelogs | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | |
| with: | |
| pattern: changelog-* | |
| merge-multiple: true | |
| path: /tmp/changelogs | |
| - name: Prepare Release | |
| id: prepare-release | |
| shell: bash | |
| run: | | |
| echo "Automated release for version \`${{ needs.build-test-promote.outputs.version }}\`." > ./changelog.md | |
| for changelog in /tmp/changelogs/*.txt; do | |
| # Remove empty Package Changes | |
| sed -i '/^#### Package Changes$/{ | |
| N | |
| N | |
| /#### Package Changes\n[[:space:]]*-[[:space:]]*\n[[:space:]]*$/d | |
| }' $changelog | |
| # Remove empty Commits | |
| sed -i '/^#### Commits$/{ | |
| N | |
| N | |
| /#### Commits\n[[:space:]]*-[[:space:]]*\n[[:space:]]*$/d | |
| }' $changelog | |
| # If there are no changes, remove the section altogether | |
| sed -zi 's/\n### Changes since[^#]*$//' $changelog | |
| cat $changelog >> ./changelog.md | |
| done | |
| - name: Create Release | |
| uses: softprops/action-gh-release@d5382d3e6f2fa7bd53cb749d33091853d4985daf # v2 | |
| with: | |
| name: "Version ${{ needs.build-test-promote.outputs.version }}" | |
| tag_name: ${{ needs.build-test-promote.outputs.version }} | |
| body_path: ./changelog.md | |
| make_latest: true |