-
Notifications
You must be signed in to change notification settings - Fork 1
117 lines (98 loc) · 4.29 KB
/
builder.yml
File metadata and controls
117 lines (98 loc) · 4.29 KB
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
name: Builder
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: --debug
- name: Get Latest Release Tag
id: tag
run: |
LATEST_RELEASE_TAG=$(curl -sL https://api.github.com/repos/Manager-io/Manager/releases/latest | jq -r '.tag_name')
echo "Latest Release Tag: $LATEST_RELEASE_TAG"
RELEASE_TAG=$(echo "${LATEST_RELEASE_TAG}" | sed 's/[~,%@+;:/ ]//g')
echo "Sanitized Release Tag: $RELEASE_TAG"
echo "LATEST_RELEASE_TAG=$LATEST_RELEASE_TAG" >> $GITHUB_OUTPUT
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_OUTPUT
# convert to lowercase
IMAGE_NAME=${REPO,,}
REPO_NAME=${IMAGE_NAME##*/}
echo "IMAGE_NAME=$IMAGE_NAME"
echo "REPO_NAME=$REPO_NAME"
echo "IMAGE_NAME=${IMAGE_NAME}" >> ${GITHUB_ENV}
echo "REPO_NAME=${REPO_NAME}" >> ${GITHUB_ENV}
HAS_PREVIOUS_RELEASE=$(curl -sL "https://api.github.com/repos/${REPO}/releases" | jq -r '.[0].tag_name // ""')
if [[ -z "$HAS_PREVIOUS_RELEASE" ]]; then
# No previous release, include all changes
echo "New build, include all changes"
CHANGES=$(curl -sL https://api.github.com/repos/Manager-io/Manager/releases | jq -r '.[].body | select(. != "no message #")' | tr '\n' '\0' | sort -u | tr '\0' '\n')
else
PREVIOUS_RELEASE=$(echo "${HAS_PREVIOUS_RELEASE}" | sed 's/[v~,%@+;:/ ]//g')
# Include changes since last release
echo "Include changes from $PREVIOUS_RELEASE"
CHANGES=$(curl -sL https://api.github.com/repos/Manager-io/Manager/releases |
jq --arg v "$PREVIOUS_RELEASE" -r 'def parse($i): $i | [sub("(?<a>[0-9]+).(?<b>[0-9]+).(?<c>[0-9]+).(?<d>[0-9]+)"; "\(.a)", "\(.b)", "\(.c)", "\(.d)")] | map(tonumber); .[] | select(parse(.tag_name) > parse($v)) | .body | select(. != "no message #")' |
tr '\n' '\0' | sort -u | tr '\0' '\n')
fi
echo "CHANGES: $CHANGES"
echo "CHANGES=$CHANGES" >> ${GITHUB_ENV}
env:
REPO: ${{ github.repository }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ vars.DOCKERHUB_USERNAME }}/${{ env.REPO_NAME }}
ghcr.io/${{ env.IMAGE_NAME }}
tags: |
type=schedule
type=sha,prefix={{branch}}-
type=pep440,pattern={{version}},value=${{ steps.tag.outputs.RELEASE_TAG }}
type=raw,value=latest,enable={{is_default_branch}}
labels: |
org.opencontainers.image.title=Manager.io
org.opencontainers.image.url=https://github.com/${{ github.repository }}/packages
org.opencontainers.image.authors=aliyusuf.com
- name: Build and push Docker image with built package
uses: docker/build-push-action@v6
with:
platforms: linux/amd64, linux/arm64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: MANAGER_VERSION=${{ steps.tag.outputs.LATEST_RELEASE_TAG }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: "v${{ steps.tag.outputs.RELEASE_TAG }}"
name: ${{ steps.tag.outputs.RELEASE_TAG }}
body: |
Updating manager to ${{ steps.tag.outputs.RELEASE_TAG }}
**Changes**
${{ env.CHANGES }}
draft: false
prerelease: false
allowUpdates: true