|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + packages: write |
| 11 | + id-token: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + release: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + |
| 22 | + - name: Save changelog |
| 23 | + run: | |
| 24 | + mkdir -p .github/release |
| 25 | + # Try to get changelog from cocogitto outputs or generate one with cog if available |
| 26 | + # Since we are on a tag, we might want to generate the changelog for this tag specifically if not present. |
| 27 | + # But cocogitto-trigger should have pushed the changelog update to main. |
| 28 | + # For the release body, we usually want the changes for *this* version. |
| 29 | + # Let's assume cog is available or we can install it to generate the changelog for the tag. |
| 30 | + # Alternatively, we can just use the CHANGELOG.md from the repo if it was updated. |
| 31 | + if [ -f CHANGELOG.md ]; then cp CHANGELOG.md .github/release/CHANGELOG.md; fi |
| 32 | +
|
| 33 | + - name: Log in to GHCR |
| 34 | + uses: docker/login-action@v2 |
| 35 | + with: |
| 36 | + registry: ghcr.io |
| 37 | + username: ${{ github.actor }} |
| 38 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + - name: Set up QEMU |
| 41 | + uses: docker/setup-qemu-action@v2 |
| 42 | + |
| 43 | + - name: Set up Docker Buildx |
| 44 | + uses: docker/setup-buildx-action@v2 |
| 45 | + |
| 46 | + - name: Build and push backend image (amd64 only, cached) |
| 47 | + uses: docker/build-push-action@v4 |
| 48 | + with: |
| 49 | + context: ./backend |
| 50 | + file: ./backend/Dockerfile |
| 51 | + push: true |
| 52 | + platforms: linux/amd64 |
| 53 | + tags: | |
| 54 | + ghcr.io/${{ github.repository_owner }}/caddymanager-backend:${{ github.ref_name }} |
| 55 | + ghcr.io/${{ github.repository_owner }}/caddymanager-backend:latest |
| 56 | + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/caddymanager-backend:buildcache |
| 57 | + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/caddymanager-backend:buildcache,mode=max |
| 58 | + |
| 59 | + - name: Build and push caddy image (amd64 only, cached) |
| 60 | + uses: docker/build-push-action@v4 |
| 61 | + with: |
| 62 | + context: ./caddy |
| 63 | + file: ./caddy/Dockerfile |
| 64 | + push: true |
| 65 | + platforms: linux/amd64 |
| 66 | + tags: | |
| 67 | + ghcr.io/${{ github.repository_owner }}/caddymanager-caddy:${{ github.ref_name }} |
| 68 | + ghcr.io/${{ github.repository_owner }}/caddymanager-caddy:latest |
| 69 | + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/caddymanager-caddy:buildcache |
| 70 | + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/caddymanager-caddy:buildcache,mode=max |
| 71 | + |
| 72 | + - name: Build and push frontend image (amd64 only, cached) |
| 73 | + uses: docker/build-push-action@v4 |
| 74 | + with: |
| 75 | + context: ./frontend |
| 76 | + file: ./frontend/Dockerfile |
| 77 | + push: true |
| 78 | + platforms: linux/amd64 |
| 79 | + tags: | |
| 80 | + ghcr.io/${{ github.repository_owner }}/caddymanager-frontend:${{ github.ref_name }} |
| 81 | + ghcr.io/${{ github.repository_owner }}/caddymanager-frontend:latest |
| 82 | + cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/caddymanager-frontend:buildcache |
| 83 | + cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/caddymanager-frontend:buildcache,mode=max |
| 84 | + |
| 85 | + - name: Create GitHub Release |
| 86 | + id: create_release |
| 87 | + uses: actions/create-release@v1 |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + with: |
| 91 | + tag_name: ${{ github.ref_name }} |
| 92 | + release_name: ${{ github.ref_name }} |
| 93 | + body_path: .github/release/CHANGELOG.md |
| 94 | + |
| 95 | + - name: Upload changelog asset |
| 96 | + uses: actions/upload-release-asset@v1 |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + with: |
| 100 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 101 | + asset_path: .github/release/CHANGELOG.md |
| 102 | + asset_name: CHANGELOG.md |
| 103 | + asset_content_type: text/markdown |
0 commit comments