diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7c6224..2445fe0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ env: jobs: build-and-push: - name: 🐳 Build and Push Docker Image + name: 🐳 Build and Push Docker Images runs-on: ubuntu-latest strategy: matrix: @@ -35,12 +35,21 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.target_arch }} tags: | + type=ref,event=tag type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - type=edge,branch=main + labels: | + org.opencontainers.image.title=${{ env.IMAGE_NAME }} + org.opencontainers.image.description=Data Proxy Service for Seda Protocol + org.opencontainers.image.version=${{ steps.meta.outputs.version }} + org.opencontainers.image.architecture=${{ matrix.target_arch }} + org.opencontainers.image.source=${{ github.repository }} + org.opencontainers.image.url=https://github.com/${{ github.repository }} + org.opencontainers.image.created=${{ steps.meta.outputs.created }} + org.opencontainers.image.revision=${{ github.sha }} - name: 🛠️ Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -52,7 +61,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: 🏗️ Build and push Docker image + - name: 🏗️ Build and push Docker image for ${{ matrix.target_arch }} uses: docker/build-push-action@v5 with: context: . @@ -66,23 +75,31 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - - name: ✨ Save image details - run: echo "${{ steps.meta.outputs.tags }}" > image-details.txt + - name: ✨ Collect image info + run: echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.target_arch }}:${{ steps.meta.outputs.version }}" >> $GITHUB_WORKSPACE/image-urls.txt - - name: 📦 Upload image details as artifact + - name: 📦 Upload image info as artifact uses: actions/upload-artifact@v3 with: - name: image-details - path: image-details.txt + name: image-urls + path: $GITHUB_WORKSPACE/image-urls.txt + if: ${{ always() }} create-release: name: 📦 Create GitHub Release needs: build-and-push runs-on: ubuntu-latest + steps: - name: 📥 Checkout code uses: actions/checkout@v4 + - name: 🔽 Download image info artifact + uses: actions/download-artifact@v3 + with: + name: image-urls + path: ./artifacts/ + - name: 📝 Generate Changelog id: changelog uses: TriPSs/conventional-changelog-action@v5.3.0 @@ -94,24 +111,24 @@ jobs: skip-git-pull: true git-push: false - - name: 🔽 Download image details artifact - uses: actions/download-artifact@v3 - with: - name: image-details - path: ./image-details.txt + - name: 📦 Prepare Release Notes + id: release_notes + run: | + echo "## Changelog" > release-body.md + echo "${{ steps.changelog.outputs.changelog }}" >> release-body.md + echo "" >> release-body.md + echo "## Docker Images" >> release-body.md + echo "The following Docker images were built and published to GHCR:" >> release-body.md + echo "" >> release-body.md + while read -r line; do + echo "- [$line](${line})" >> release-body.md + done < ./artifacts/image-urls.txt - name: 🎉 Create GitHub Release uses: ncipollo/release-action@v1 with: allowUpdates: true - generateReleaseNotes: true - body: | - ${{ steps.changelog.outputs.changelog }} - - ## Docker Images - The following Docker images were built and published: - ``` - ${{ steps.changelog.outputs.changelog }} - ${{ steps.release.outputs.uploaded }} - ``` + tag: ${{ github.ref_name }} + name: ${{ github.ref_name }} + body: ${{ steps.release_notes.outputs.body }} token: ${{ secrets.GITHUB_TOKEN }}