-
Notifications
You must be signed in to change notification settings - Fork 1.3k
95 lines (82 loc) · 2.8 KB
/
cd.docker.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
name: cd·docker
on:
release:
types:
- published
workflow_dispatch:
inputs:
tag:
required: true
concurrency:
group: docker/${{ github.event.release.tag_name || github.event.inputs.tag }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
build-and-push-image:
name: docker buildx pkgxdev/pkgx:${{ github.event.release.tag_name || github.event.inputs.tag }}
runs-on: ubuntu-latest
steps:
- uses: robinraju/release-downloader@v1.11
with:
releaseId: ${{ github.event.release.id }}
tag: ${{ github.event.inputs.tag }}
fileName: pkgx-*.tar.xz
- name: is_latest?
id: latest
run: |
TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.tag }}"
LATEST_RELEASE=$(gh api repos/${{ github.repository }}/releases/latest --jq '.tag_name')
if [ "$TAG_NAME" == "$LATEST_RELEASE" ]; then
echo "value=true" >> "${GITHUB_OUTPUT}"
else
echo "value=false" >> "${GITHUB_OUTPUT}"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Unpack Binaries
run: |
for filename in pkgx-*+*+*.tar.xz; do
tar xJf $filename
result="${filename#*+}"
result="${result%.tar.xz}"
mv pkgx $result
rm $filename
done
mkdir products
mv linux+x86-64 products/x86_64
mv linux+aarch64 products/aarch64
curl -o products/pkgm https://pkgxdev.github.io/pkgm/pkgm.ts
- uses: actions/checkout@v4
with:
path: src
- name: log in to docker hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER_NAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: pkgxdev/pkgx
flavor: |
latest=${{ steps.latest.outputs.value }}
tags: |
type=sha
type=semver,pattern=v{{version}},value=${{ github.event.release.tag_name || github.event.inputs.tag }}
type=semver,pattern=v{{major}}.{{minor}},value=${{ github.event.release.tag_name || github.event.inputs.tag }}
type=semver,pattern=v{{major}},value=${{ github.event.release.tag_name || github.event.inputs.tag }}
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: docker/buildx
run: |
for x in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' ');
do tags="$tags --tag $x";
done
docker buildx build \
--push \
$tags \
--platform linux/amd64,linux/arm64 \
--file ./src/.github/Dockerfile \
.