release-packages-and-images #15
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-packages-and-images | |
| # Workflow to build and release the following MicroShift artifacts: | |
| # - RPM packages | |
| # - DEB packages | |
| # - Bootc container images | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| ushift-gitref: | |
| default: "main" | |
| description: MicroShift git ref (branch, tag, commit) from https://github.com/openshift/microshift/branches | |
| type: string | |
| okd-version-tag: | |
| default: "latest" | |
| description: OKD version tag from https://quay.io/repository/okd/scos-release?tab=tags | |
| type: string | |
| build: | |
| type: choice | |
| description: Types of artifacts to build | |
| default: all | |
| options: | |
| - all | |
| - packages | |
| - bootc-image | |
| jobs: | |
| build-microshift: | |
| strategy: | |
| matrix: | |
| runners: [ubuntu-24.04, ubuntu-24.04-arm] | |
| name: Build MicroShift upstream | |
| runs-on: ${{ matrix.runners }} | |
| steps: | |
| - name: Check out MicroShift upstream repository | |
| uses: actions/checkout@v4 | |
| - name: Detect the CPU architecture | |
| id: detect-cpu-arch | |
| uses: ./.github/actions/arch | |
| - name: Detect OKD version tag | |
| id: detect-okd-version | |
| uses: ./.github/actions/okd-version | |
| - name: Run the build action | |
| uses: ./.github/actions/build | |
| with: | |
| ushift-gitref: ${{ inputs.ushift-gitref }} | |
| okd-version-tag: ${{ inputs.okd-version-tag != 'latest' && inputs.okd-version-tag || steps.detect-okd-version.outputs.okd-version-tag }} | |
| bootc-image-url: quay.io/centos-bootc/centos-bootc | |
| bootc-image-tag: stream10 | |
| build: ${{ inputs.build }} | |
| # Test the local container image with the quick start and clean procedures | |
| # before releasing the artifacts. Make sure not to run the clean scripts | |
| # because the images are needed for the release process. | |
| - name: Run the quick start script and clean scripts | |
| if: contains(fromJSON('["all", "bootc-image"]'), inputs.build) | |
| uses: ./.github/actions/quick-start-clean | |
| with: | |
| image-ref: localhost/microshift-okd:latest | |
| run-clean: false | |
| # Prepare the RPM archives to be released before converting to DEB packages. | |
| - name: Prepare the RPM archives | |
| if: contains(fromJSON('["all", "packages"]'), inputs.build) | |
| shell: bash | |
| run : | | |
| # Archive sources separately from the RPMs | |
| sudo mv /mnt/rpms/srpms /mnt/srpms | |
| cd /mnt/srpms | |
| sudo tar zcvf /mnt/release/microshift-src.tgz . | |
| cd /mnt/rpms | |
| sudo tar zcvf /mnt/release/microshift-rpms-$(uname -m).tgz . | |
| - name: Store version in a variable | |
| id: version | |
| run: | | |
| set -euo pipefail | |
| if [ ! -f /mnt/rpms/version.txt ]; then | |
| echo "ERROR: version.txt not found at /mnt/rpms/version.txt" | |
| exit 1 | |
| fi | |
| echo "version=$(cat /mnt/rpms/version.txt)" >> "${GITHUB_OUTPUT}" | |
| - name: Push version.txt to artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: version.txt | |
| path: /mnt/rpms/version.txt | |
| overwrite: true | |
| # This step is run after the RPM archives are prepared to avoid | |
| # including DEB packages in the RPM archive. | |
| - name: Convert the RPMs to DEB packages | |
| if: contains(fromJSON('["all", "packages"]'), inputs.build) | |
| uses: ./.github/actions/build-deb | |
| with: | |
| ushift-gitref: ${{ inputs.ushift-gitref }} | |
| okd-version-tag: ${{ inputs.okd-version-tag != 'latest' && inputs.okd-version-tag || steps.detect-okd-version.outputs.okd-version-tag }} | |
| build-rpms: false | |
| - name: Prepare the DEB archives | |
| if: contains(fromJSON('["all", "packages"]'), inputs.build) | |
| shell: bash | |
| run: | | |
| cd /mnt/rpms/deb | |
| sudo tar zcvf /mnt/release/microshift-debs-$(uname -m).tgz . | |
| - name: Release RPM and DEB packages | |
| if: contains(fromJSON('["all", "packages"]'), inputs.build) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.version }} | |
| files: | | |
| /mnt/release/microshift-rpms-*.tgz | |
| /mnt/release/microshift-debs-*.tgz | |
| /mnt/release/microshift-src.tgz | |
| overwrite_files: true | |
| - name: Login to GitHub Container Registry | |
| if: contains(fromJSON('["all", "bootc-image"]'), inputs.build) | |
| uses: ./.github/actions/podman-login | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish Bootc container image for the target architecture | |
| if: contains(fromJSON('["all", "bootc-image"]'), inputs.build) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| set -x | |
| TARGET_IMAGE="ghcr.io/${{ github.repository_owner }}/microshift" | |
| TARGET_TAG="${{ steps.version.outputs.version }}-${{ steps.detect-cpu-arch.outputs.go_arch }}" | |
| sudo podman tag microshift-okd "${TARGET_IMAGE}:${TARGET_TAG}" | |
| sudo podman push "${TARGET_IMAGE}:${TARGET_TAG}" | |
| release-microshift: | |
| needs: build-microshift | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Check out MicroShift upstream repository | |
| uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: version.txt | |
| path: /tmp/ | |
| - name: Store version in a variable | |
| id: version | |
| run: | | |
| echo "version=$(cat /tmp/version.txt)" >> "${GITHUB_OUTPUT}" | |
| - name: Login to GitHub Container Registry | |
| if: contains(fromJSON('["all", "bootc-image"]'), inputs.build) | |
| uses: ./.github/actions/podman-login | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish Bootc container image manifest | |
| if: contains(fromJSON('["all", "bootc-image"]'), inputs.build) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| set -x | |
| TARGET_IMAGE="ghcr.io/${{ github.repository_owner }}/microshift" | |
| TARGET_TAG="${{ steps.version.outputs.version }}" | |
| sudo podman manifest create "${TARGET_IMAGE}:${TARGET_TAG}" | |
| sudo podman manifest add "${TARGET_IMAGE}:${TARGET_TAG}" "${TARGET_IMAGE}:${TARGET_TAG}-amd64" | |
| sudo podman manifest add "${TARGET_IMAGE}:${TARGET_TAG}" "${TARGET_IMAGE}:${TARGET_TAG}-arm64" | |
| sudo podman manifest push "${TARGET_IMAGE}:${TARGET_TAG}" | |
| # Prepare the release note for the bootc image usage | |
| OWNER="${{ github.repository_owner }}" IMAGE="${TARGET_IMAGE}" TAG="${TARGET_TAG}" \ | |
| envsubst < .github/workflows/release.md > /tmp/release.md | |
| - name: Add release note for bootc image usage | |
| if: contains(fromJSON('["all", "bootc-image"]'), inputs.build) | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.version }} | |
| body_path: /tmp/release.md |