|
1 | 1 | name: Build-Docker |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: [created] |
| 4 | + release: |
| 5 | + types: [created] |
6 | 6 |
|
7 | 7 | permissions: |
8 | | - contents: write |
9 | | - packages: write |
| 8 | + contents: write |
| 9 | + packages: write |
10 | 10 |
|
11 | 11 | env: |
12 | | - IMAGE_NAME: pasarguard/${{ github.event.repository.name }} |
13 | | - FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 12 | + IMAGE_NAME: pasarguard/${{ github.event.repository.name }} |
| 13 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
14 | 14 |
|
15 | 15 | jobs: |
16 | | - generate-changelog: |
17 | | - runs-on: ubuntu-latest |
18 | | - steps: |
19 | | - - name: Checkout |
20 | | - uses: actions/checkout@v6 |
21 | | - with: |
22 | | - fetch-depth: 0 |
23 | | - |
24 | | - - name: Determine version range |
25 | | - id: tags |
26 | | - run: | |
27 | | - current_tag="${GITHUB_REF_NAME}" |
28 | | - prev_tag="$(git describe --tags --abbrev=0 "${current_tag}^" 2>/dev/null || true)" |
29 | | - if [ -z "$prev_tag" ]; then |
30 | | - prev_tag="$(git rev-list --max-parents=0 HEAD)" |
31 | | - fi |
32 | | - echo "previous=$prev_tag" >> "$GITHUB_OUTPUT" |
33 | | - echo "current=$current_tag" >> "$GITHUB_OUTPUT" |
34 | | -
|
35 | | - - name: Setup Bun |
36 | | - uses: oven-sh/setup-bun@v2 |
37 | | - with: |
38 | | - bun-version: latest |
39 | | - |
40 | | - - name: Generate changelog |
41 | | - run: | |
42 | | - bunx changelogen@latest --from "${{ steps.tags.outputs.previous }}" --to "${{ steps.tags.outputs.current }}" \ |
43 | | - | grep -v "Generating changelog for " > CHANGELOG.md |
44 | | -
|
45 | | - - name: Update release notes |
46 | | - env: |
47 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
48 | | - run: | |
49 | | - gh release edit "${{ github.event.release.tag_name }}" --notes-file CHANGELOG.md |
50 | | -
|
51 | | - - name: Upload changelog artifact |
52 | | - uses: actions/upload-artifact@v7 |
53 | | - with: |
54 | | - name: changelog |
55 | | - path: CHANGELOG.md |
56 | | - retention-days: 7 |
57 | | - |
58 | | - build-dashboard: |
59 | | - needs: generate-changelog |
60 | | - runs-on: ubuntu-latest |
61 | | - steps: |
62 | | - - name: Checkout |
63 | | - uses: actions/checkout@v6 |
64 | | - |
65 | | - - name: Setup Bun |
66 | | - uses: oven-sh/setup-bun@v2 |
67 | | - with: |
68 | | - bun-version: latest |
69 | | - |
70 | | - - name: Install dependencies |
71 | | - working-directory: ./dashboard |
72 | | - run: bun install --frozen-lockfile |
73 | | - |
74 | | - - name: Build dashboard |
75 | | - run: ./build_dashboard.sh |
76 | | - |
77 | | - - name: Upload dashboard build |
78 | | - uses: actions/upload-artifact@v7 |
79 | | - with: |
80 | | - name: dashboard-build |
81 | | - path: ./dashboard/build/ |
82 | | - retention-days: 1 |
83 | | - |
84 | | - build-images: |
85 | | - needs: build-dashboard |
86 | | - strategy: |
87 | | - matrix: |
88 | | - arch: [amd64, arm64] |
89 | | - include: |
90 | | - - arch: amd64 |
91 | | - platform: linux/amd64 |
92 | | - runner: ubuntu-24.04 |
93 | | - - arch: arm64 |
94 | | - platform: linux/arm64 |
95 | | - runner: ubuntu-24.04-arm |
96 | | - runs-on: ${{ matrix.runner }} |
97 | | - steps: |
98 | | - - name: Checkout |
99 | | - uses: actions/checkout@v6 |
100 | | - |
101 | | - - name: Download dashboard build |
102 | | - uses: actions/download-artifact@v8 |
103 | | - with: |
104 | | - name: dashboard-build |
105 | | - path: ./dashboard/build/ |
106 | | - |
107 | | - - name: Set up Docker Buildx |
108 | | - uses: docker/setup-buildx-action@v4 |
109 | | - |
110 | | - - name: Login to Docker Hub |
111 | | - uses: docker/login-action@v4 |
112 | | - with: |
113 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
114 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
115 | | - |
116 | | - - name: Login to GitHub Container Registry |
117 | | - uses: docker/login-action@v4 |
118 | | - with: |
119 | | - registry: ghcr.io |
120 | | - username: ${{ github.repository_owner }} |
121 | | - password: ${{ secrets.GITHUB_TOKEN }} |
122 | | - |
123 | | - - name: Build and push ${{ matrix.arch }} image |
124 | | - uses: docker/build-push-action@v7 |
125 | | - with: |
126 | | - context: . |
127 | | - platforms: ${{ matrix.platform }} |
128 | | - push: true |
129 | | - file: ./Dockerfile |
130 | | - tags: | |
131 | | - ${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.arch }} |
132 | | - ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.arch }} |
133 | | - cache-from: type=gha |
134 | | - cache-to: type=gha,mode=max |
135 | | - |
136 | | - push-manifest: |
137 | | - needs: [build-images] |
138 | | - runs-on: ubuntu-latest |
139 | | - steps: |
140 | | - - name: Login to Docker Hub |
141 | | - uses: docker/login-action@v4 |
142 | | - with: |
143 | | - username: ${{ secrets.DOCKERHUB_USERNAME }} |
144 | | - password: ${{ secrets.DOCKERHUB_TOKEN }} |
145 | | - |
146 | | - - name: Login to GitHub Container Registry |
147 | | - uses: docker/login-action@v4 |
148 | | - with: |
149 | | - registry: ghcr.io |
150 | | - username: ${{ github.repository_owner }} |
151 | | - password: ${{ secrets.GITHUB_TOKEN }} |
152 | | - |
153 | | - - name: Set up Docker Buildx |
154 | | - uses: docker/setup-buildx-action@v4 |
155 | | - |
156 | | - - name: Create tagged manifest |
157 | | - run: | |
158 | | - docker buildx imagetools create \ |
159 | | - -t "${{ env.IMAGE_NAME }}:${{ github.ref_name }}" \ |
160 | | - "${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64" \ |
161 | | - "${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64" |
162 | | - docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:${{ github.ref_name }}" |
163 | | -
|
164 | | - - name: Create tagged manifest for GitHub |
165 | | - run: | |
166 | | - docker buildx imagetools create \ |
167 | | - -t "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}" \ |
168 | | - "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64" \ |
169 | | - "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64" |
170 | | - docker buildx imagetools inspect "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}" |
171 | | -
|
172 | | - - name: Create latest manifest if not prerelease |
173 | | - if: ${{ github.event.release.prerelease != true }} |
174 | | - run: | |
175 | | - docker buildx imagetools create \ |
176 | | - -t "${{ env.IMAGE_NAME }}:latest" \ |
177 | | - "${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64" \ |
178 | | - "${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64" |
179 | | - docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:latest" |
180 | | -
|
181 | | - - name: Create latest manifest for GitHub if not prerelease |
182 | | - if: ${{ github.event.release.prerelease != true }} |
183 | | - run: | |
184 | | - docker buildx imagetools create \ |
185 | | - -t "ghcr.io/${{ env.IMAGE_NAME }}:latest" \ |
186 | | - "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64" \ |
187 | | - "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64" |
188 | | - docker buildx imagetools inspect "ghcr.io/${{ env.IMAGE_NAME }}:latest" |
| 16 | + generate-changelog: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v6 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Determine version range |
| 25 | + id: tags |
| 26 | + env: |
| 27 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + CURRENT_IS_PRERELEASE: ${{ github.event.release.prerelease }} |
| 29 | + run: | |
| 30 | + current_tag="${GITHUB_REF_NAME}" |
| 31 | + prev_tag="" |
| 32 | +
|
| 33 | + if [ "${CURRENT_IS_PRERELEASE}" != "true" ]; then |
| 34 | + prev_tag="$(gh api --paginate --slurp "repos/${GITHUB_REPOSITORY}/releases" \ |
| 35 | + --jq '[.[][] | select(.draft == false and .prerelease == false and .tag_name != "'"$current_tag"'") | .tag_name][0] // empty')" |
| 36 | + fi |
| 37 | +
|
| 38 | + if [ -z "$prev_tag" ]; then |
| 39 | + prev_tag="$(git describe --tags --abbrev=0 "${current_tag}^" 2>/dev/null || true)" |
| 40 | + fi |
| 41 | +
|
| 42 | + if [ -z "$prev_tag" ]; then |
| 43 | + prev_tag="$(git rev-list --max-parents=0 HEAD)" |
| 44 | + fi |
| 45 | +
|
| 46 | + echo "previous=$prev_tag" >> "$GITHUB_OUTPUT" |
| 47 | + echo "current=$current_tag" >> "$GITHUB_OUTPUT" |
| 48 | +
|
| 49 | + - name: Setup Bun |
| 50 | + uses: oven-sh/setup-bun@v2 |
| 51 | + with: |
| 52 | + bun-version: latest |
| 53 | + |
| 54 | + - name: Generate changelog |
| 55 | + run: | |
| 56 | + bunx changelogen@latest --from "${{ steps.tags.outputs.previous }}" --to "${{ steps.tags.outputs.current }}" \ |
| 57 | + | grep -v "Generating changelog for " > CHANGELOG.md |
| 58 | +
|
| 59 | + - name: Update release notes |
| 60 | + env: |
| 61 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + run: | |
| 63 | + gh release edit "${{ github.event.release.tag_name }}" --notes-file CHANGELOG.md |
| 64 | +
|
| 65 | + - name: Upload changelog artifact |
| 66 | + uses: actions/upload-artifact@v7 |
| 67 | + with: |
| 68 | + name: changelog |
| 69 | + path: CHANGELOG.md |
| 70 | + retention-days: 7 |
| 71 | + |
| 72 | + build-dashboard: |
| 73 | + needs: generate-changelog |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - name: Checkout |
| 77 | + uses: actions/checkout@v6 |
| 78 | + |
| 79 | + - name: Setup Bun |
| 80 | + uses: oven-sh/setup-bun@v2 |
| 81 | + with: |
| 82 | + bun-version: latest |
| 83 | + |
| 84 | + - name: Install dependencies |
| 85 | + working-directory: ./dashboard |
| 86 | + run: bun install --frozen-lockfile |
| 87 | + |
| 88 | + - name: Build dashboard |
| 89 | + run: ./build_dashboard.sh |
| 90 | + |
| 91 | + - name: Upload dashboard build |
| 92 | + uses: actions/upload-artifact@v7 |
| 93 | + with: |
| 94 | + name: dashboard-build |
| 95 | + path: ./dashboard/build/ |
| 96 | + retention-days: 1 |
| 97 | + |
| 98 | + build-images: |
| 99 | + needs: build-dashboard |
| 100 | + strategy: |
| 101 | + matrix: |
| 102 | + arch: [amd64, arm64] |
| 103 | + include: |
| 104 | + - arch: amd64 |
| 105 | + platform: linux/amd64 |
| 106 | + runner: ubuntu-24.04 |
| 107 | + - arch: arm64 |
| 108 | + platform: linux/arm64 |
| 109 | + runner: ubuntu-24.04-arm |
| 110 | + runs-on: ${{ matrix.runner }} |
| 111 | + steps: |
| 112 | + - name: Checkout |
| 113 | + uses: actions/checkout@v6 |
| 114 | + |
| 115 | + - name: Download dashboard build |
| 116 | + uses: actions/download-artifact@v8 |
| 117 | + with: |
| 118 | + name: dashboard-build |
| 119 | + path: ./dashboard/build/ |
| 120 | + |
| 121 | + - name: Set up Docker Buildx |
| 122 | + uses: docker/setup-buildx-action@v4 |
| 123 | + |
| 124 | + - name: Login to Docker Hub |
| 125 | + uses: docker/login-action@v4 |
| 126 | + with: |
| 127 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 128 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 129 | + |
| 130 | + - name: Login to GitHub Container Registry |
| 131 | + uses: docker/login-action@v4 |
| 132 | + with: |
| 133 | + registry: ghcr.io |
| 134 | + username: ${{ github.repository_owner }} |
| 135 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 136 | + |
| 137 | + - name: Build and push ${{ matrix.arch }} image |
| 138 | + uses: docker/build-push-action@v7 |
| 139 | + with: |
| 140 | + context: . |
| 141 | + platforms: ${{ matrix.platform }} |
| 142 | + push: true |
| 143 | + file: ./Dockerfile |
| 144 | + tags: | |
| 145 | + ${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.arch }} |
| 146 | + ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ matrix.arch }} |
| 147 | + cache-from: type=gha |
| 148 | + cache-to: type=gha,mode=max |
| 149 | + |
| 150 | + push-manifest: |
| 151 | + needs: [build-images] |
| 152 | + runs-on: ubuntu-latest |
| 153 | + steps: |
| 154 | + - name: Login to Docker Hub |
| 155 | + uses: docker/login-action@v4 |
| 156 | + with: |
| 157 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 158 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 159 | + |
| 160 | + - name: Login to GitHub Container Registry |
| 161 | + uses: docker/login-action@v4 |
| 162 | + with: |
| 163 | + registry: ghcr.io |
| 164 | + username: ${{ github.repository_owner }} |
| 165 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 166 | + |
| 167 | + - name: Set up Docker Buildx |
| 168 | + uses: docker/setup-buildx-action@v4 |
| 169 | + |
| 170 | + - name: Create tagged manifest |
| 171 | + run: | |
| 172 | + docker buildx imagetools create \ |
| 173 | + -t "${{ env.IMAGE_NAME }}:${{ github.ref_name }}" \ |
| 174 | + "${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64" \ |
| 175 | + "${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64" |
| 176 | + docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:${{ github.ref_name }}" |
| 177 | +
|
| 178 | + - name: Create tagged manifest for GitHub |
| 179 | + run: | |
| 180 | + docker buildx imagetools create \ |
| 181 | + -t "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}" \ |
| 182 | + "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64" \ |
| 183 | + "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64" |
| 184 | + docker buildx imagetools inspect "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}" |
| 185 | +
|
| 186 | + - name: Create latest manifest if not prerelease |
| 187 | + if: ${{ github.event.release.prerelease != true }} |
| 188 | + run: | |
| 189 | + docker buildx imagetools create \ |
| 190 | + -t "${{ env.IMAGE_NAME }}:latest" \ |
| 191 | + "${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64" \ |
| 192 | + "${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64" |
| 193 | + docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:latest" |
| 194 | +
|
| 195 | + - name: Create latest manifest for GitHub if not prerelease |
| 196 | + if: ${{ github.event.release.prerelease != true }} |
| 197 | + run: | |
| 198 | + docker buildx imagetools create \ |
| 199 | + -t "ghcr.io/${{ env.IMAGE_NAME }}:latest" \ |
| 200 | + "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-amd64" \ |
| 201 | + "ghcr.io/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-arm64" |
| 202 | + docker buildx imagetools inspect "ghcr.io/${{ env.IMAGE_NAME }}:latest" |
0 commit comments