Build images #93
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: Build images | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release: | |
| required: true | |
| type: string | |
| description: "The tag name of the MinIO release to build (e.g., RELEASE.2023-05-04T21-44-30Z)" | |
| schedule: | |
| # Run weekly at midnight on Sunday | |
| - cron: '0 0 * * *' | |
| env: | |
| IMAGE: 'proof-partners/minio' | |
| VERSION: ${{ github.event.inputs.release || '' }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| get-tags: | |
| runs-on: ubuntu-latest | |
| # Only run this job if triggered by the schedule, not manually | |
| if: github.event_name == 'schedule' | |
| outputs: | |
| latest_release: ${{ steps.get-latest-release.outputs.latest_release }} | |
| previous_build: ${{ steps.get-latest-build.outputs.previous_build }} | |
| steps: | |
| - name: Get latest release | |
| id: get-latest-release | |
| run: | | |
| LATEST_RELEASE=$(curl -s https://api.github.com/repos/minio/minio/releases | jq -r '.[] | select(.tag_name | test("RELEASE.*")) | .tag_name' | head -n 1) | |
| echo "latest_release=${LATEST_RELEASE}" >> $GITHUB_OUTPUT | |
| echo "Latest release: ${LATEST_RELEASE}" | |
| - name: Get latest built image | |
| id: get-latest-build | |
| env: | |
| IMAGE: ${{ env.IMAGE }} | |
| run: | | |
| ENCODED_TOKEN=$(echo -n "${{ secrets.GITHUB_TOKEN }}" | base64) | |
| TAG=$(curl -s -H "Authorization: Bearer ${ENCODED_TOKEN}" "https://ghcr.io/v2/${IMAGE}/tags/list" \ | |
| | jq '.tags[]' | sed -E 's/^.+(RELEASE\..+)"$/\1/' | awk '/RELEASE/' | sort | tail -n 1) | |
| echo "previous_build=${TAG}" >> $GITHUB_OUTPUT | |
| echo "Previous build: ${TAG}" | |
| build: | |
| # For manual runs, run directly | |
| # For scheduled runs, only run if check-latest-release determined there's a new release | |
| needs: [get-tags] | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'schedule' && | |
| needs.get-tags.outputs.latest-release != needs.get-tags.outputs.previous_build) | |
| strategy: | |
| matrix: | |
| OS: [linux, windows] | |
| ARCH: [amd64, arm64] | |
| exclude: | |
| - OS: windows | |
| ARCH: arm64 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set VERSION env var | |
| run: | | |
| if [ "${{ github.event_name }}" == "schedule" ]; then | |
| echo "VERSION=${{ needs.get-tags.outputs.latest_release }}" >> $GITHUB_ENV | |
| echo "Using latest version: ${{ needs.check-latest-release.outputs.latest_release }}" | |
| else | |
| echo "Using manually specified version: ${{ github.event.inputs.release }}" | |
| fi | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login github container registry | |
| run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Run the workflow | |
| env: | |
| IMAGE: ${{ env.IMAGE }} | |
| OS: ${{ matrix.OS }} | |
| ARCH: ${{ matrix.ARCH }} | |
| VERSION: ${{ env.VERSION }} | |
| run: docker buildx bake |