-
Notifications
You must be signed in to change notification settings - Fork 2
152 lines (135 loc) · 4.48 KB
/
release-dockerhub.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
name: release-dockerhub
on:
push:
branches:
- main
paths:
- 'src/*.js'
- 'Dockerfile'
- 'package.json'
env:
TMP_LOCAL_IMAGE: localhost:5000/${{ github.repository }}
REGISTRY_IMAGE: ${{ github.repository }}
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
REGISTRY_TAG: latest
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
check_release:
runs-on: ubuntu-latest
outputs:
version: ${{steps.check.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: CheckRelease
id: check
run: |
VERSION=$(curl -s https://api.github.com/repos/tsaridas/jackett-stremio/releases/latest | grep \"name | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
IFS='.' read -ra version_parts <<< "$VERSION"
major="${version_parts[0]}"
minor="${version_parts[1]}"
last_digit="${version_parts[2]}"
new_last_digit=$((last_digit + 1))
NEWVERSION="$major.$minor.$new_last_digit"
echo "We will release $NEWVERSION"
echo "version=$NEWVERSION" >> $GITHUB_OUTPUT
jq ".version = \"$NEWVERSION\"" < package.json > package.json.tmp && mv package.json.tmp package.json
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add package.json
git commit -m "Update version to $NEWVERSION"
git push
build:
runs-on: ubuntu-latest
needs:
- check_release
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm/v6
- linux/arm/v7
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Prepare
run: |
mkdir -p /tmp/images
platform=${{ matrix.platform }}
echo "TARFILE=${platform//\//-}.tar" >> $GITHUB_ENV
echo "TAG=${{ env.TMP_LOCAL_IMAGE }}:${platform//\//-}" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ matrix.platform }}
build-args: |
VERSION=v${{ needs.check_release.outputs.version }}
tags: ${{ env.TAG }}
outputs: type=docker,dest=/tmp/images/${{ env.TARFILE }}
- name: Load images
run: |
for image in /tmp/images/*.tar; do
docker load -i $image
done
- name: Upload image
uses: actions/upload-artifact@v3
with:
name: images
path: /tmp/images/${{ env.TARFILE }}
if-no-files-found: error
retention-days: 1
push:
runs-on: ubuntu-latest
needs:
- build
- check_release
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Download images
uses: actions/download-artifact@v3
with:
name: images
path: /tmp/images
- name: Load images
run: |
for image in /tmp/images/*.tar; do
docker load -i $image
done
- name: Push images to local registry
run: |
docker push -a ${{ env.TMP_LOCAL_IMAGE }}
- name: Login to DockerHUB
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASS }}
- name: Create manifest list and push
run: |
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }} -t ${{ env.REGISTRY_IMAGE }}:v${{ needs.check_release.outputs.version }} \
$(docker image ls --format '{{.Repository}}:{{.Tag}}' '${{ env.TMP_LOCAL_IMAGE }}' | tr '\n' ' ')
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.REGISTRY_TAG }}
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:v${{ needs.check_release.outputs.version }}
release:
runs-on: ubuntu-latest
needs:
- build
- check_release
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Release
run: |
gh release create v${{ needs.check_release.outputs.version }} --title "Release v${{ needs.check_release.outputs.version }}" --notes "New Release"