-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (139 loc) Β· 5.1 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: π Release
on:
push:
tags: ["*"]
permissions:
contents: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: sedaprotocol/seda-data-proxy
jobs:
build-and-push:
name: π³ Build and Push Docker Images
runs-on: ubuntu-latest
strategy:
matrix:
target_arch:
- bun-linux-x64-modern
- bun-linux-arm64
- bun-darwin-arm64
include:
- target_arch: bun-linux-x64-modern
platform: linux/amd64
- target_arch: bun-linux-arm64
platform: linux/arm64
- target_arch: bun-darwin-arm64
platform: darwin/arm64
steps:
- name: π₯ Checkout code
uses: actions/checkout@v4
- name: π·οΈ Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
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}}
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
- name: π Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: ποΈ Build and push Docker image for ${{ matrix.target_arch }}
uses: docker/build-push-action@v5
with:
context: .
file: .build/docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
TARGET_ARCH=${{ matrix.target_arch }}
platforms: ${{ matrix.platform }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: β¨ Collect image info
run: |
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ matrix.target_arch }}:${{ steps.meta.outputs.version }}" >> image-urls-${{ matrix.target_arch }}.txt
- name: π¦ Upload image info as artifact
uses: actions/upload-artifact@v3
with:
name: image-urls-${{ matrix.target_arch }}
path: image-urls-${{ matrix.target_arch }}.txt
if: ${{ always() }}
collect-artifacts:
name: π₯ Collect Artifacts
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: π½ Download all artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts/
- name: π Combine image URLs
run: |
cat ./artifacts/image-urls-*.txt > combined-image-urls.txt
- name: π¦ Upload combined image URLs
uses: actions/upload-artifact@v3
with:
name: combined-image-urls
path: combined-image-urls.txt
create-release:
name: π¦ Create GitHub Release
needs: collect-artifacts
runs-on: ubuntu-latest
steps:
- name: π₯ Checkout code
uses: actions/checkout@v4
- name: π½ Download combined image URLs
uses: actions/download-artifact@v3
with:
name: combined-image-urls
path: ./artifacts/
- name: π Generate Changelog
id: changelog
uses: TriPSs/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
output-file: false
skip-commit: true
skip-tag: true
skip-git-pull: true
git-push: false
- 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/combined-image-urls.txt
echo "::set-output name=body::$(cat release-body.md)"
- name: π Create GitHub Release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
tag: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: ${{ steps.release_notes.outputs.body }}
token: ${{ secrets.GITHUB_TOKEN }}