diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 43d926a..c4353e7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -75,10 +75,7 @@ jobs: with: images: quay.io/tinkerbell/rufio tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} + type=raw,value=latest,enable={{is_default_branch}} type=ref,event=branch,enable=${{ !startsWith(github.ref, 'refs/heads/main') }} type=ref,event=pr type=sha diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1dfd812..ffefa5d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -12,6 +12,46 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + + - name: Login to quay.io + uses: docker/login-action@v1 + with: + registry: quay.io + username: ${{ secrets.QUAY_USERNAME }} + password: ${{ secrets.QUAY_PASSWORD }} + + # This action generates the source image name and should coincide with the build + # from the ci.yaml workflow. + - name: Generate source image + id: src + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: latest=false + tags: | + type=sha + + - name: Docker manager metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: latest=false + tags: | + type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + # TODO(chrisdoherty4) The meta action generates Docker tags with a 7 character short sha. + # We need to figure out a way to generate that + - name: Push image + uses: akhilerm/tag-push-action@v2.0.0 + with: + src: ${{ steps.src.outputs.tags }} + dst: | + ${{ steps.meta.outputs.tags }} + - name: Generate Release Notes run: | release_notes=$(gh api repos/{owner}/{repo}/releases/generate-notes -F tag_name=${{ github.ref }} --jq .body) @@ -23,25 +63,6 @@ jobs: OWNER: ${{ github.repository_owner }} REPO: ${{ github.event.repository.name }} - - name: Docker manager metadata - id: meta - uses: docker/metadata-action@v3 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - flavor: latest=false - tags: type=ref,event=tag - - - name: Set the from image tag - run: echo "FROM_TAG=sha-${GITHUB_SHA::8}" >> $GITHUB_ENV - - - name: Copy the image using skopeo - run: skopeo copy --all --dest-creds="${DST_REG_USER}":"${DST_REG_PASS}" docker://"${SRC_IMAGE}" docker://"${DST_IMAGE}" - env: - SRC_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.FROM_TAG }} - DST_IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} - DST_REG_USER: ${{ secrets.QUAY_USERNAME }} - DST_REG_PASS: ${{ secrets.QUAY_PASSWORD }} - - name: Create Release id: create_release uses: actions/create-release@v1