Skip to content

Commit 646ed11

Browse files
authored
refactor(docker): Roll our own push to GH package registry (#105)
The official GH Action for this gets worse and worse with every version, and the old versions aren't properly supported any more. cf. docker/build-push-action#208 This isn't actually that hard, and with a make rule for it we have the option to build and push locally.
1 parent 63ba001 commit 646ed11

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

.github/workflows/deploy.yml

+12-20
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,9 @@ on:
66
- 'v*.*.*'
77

88
jobs:
9-
ghpackages:
10-
11-
runs-on: ubuntu-20.04
12-
13-
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v2
16-
- name: Push to GitHub Packages
17-
uses: docker/build-push-action@v1
18-
with:
19-
username: ${{ github.actor }}
20-
password: ${{ github.token }}
21-
registry: docker.pkg.github.com
22-
repository: sile-typesetter/casile/casile
23-
tag_with_ref: true
24-
25-
ghrelease:
26-
27-
runs-on: ubuntu-20.04
289

10+
ghpublish:
11+
runs-on: ubuntu-latest
2912
steps:
3013
- name: Checkout
3114
uses: actions/checkout@v2
@@ -47,11 +30,20 @@ jobs:
4730
name: casile-${{ env.VERSION }}
4831
path: casile*-${{ env.VERSION }}.zip
4932
- name: Publish Release
50-
uses: softprops/action-gh-release@v0.1.5
33+
uses: softprops/action-gh-release@v1
5134
with:
5235
body_path: casile-${{ env.VERSION }}.md
5336
files: |
5437
casile-${{ env.VERSION }}.zip
5538
casile-${{ env.VERSION }}.tar.xz
5639
env:
5740
GITHUB_TOKEN: ${{ github.token }}
41+
- name: Publish Docker Image to GH Pakcages
42+
run: |
43+
make docker-build-push
44+
env:
45+
DOCKER_REGISTRY: docker.pkg.github.com
46+
DOCKER_REPO: $GITHUB_REPOSITORY/casile
47+
DOCKER_TAG: ${{ env.VERSION }}
48+
DOCKER_USERNAME: ${{ github.actor }}
49+
DOCKER_PASSWORD: ${{ github.token }}

Makefile.am

+12-1
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,17 @@ casile-%.md: CHANGELOG.md
209209
sed -e '/\.\.\.v$*/,/\.\.\.v/!d' $< | \
210210
sed -e '1,3d;N;$$!P;$$!D;$$d' > $@
211211

212+
export DOCKER_REGISTRY ?= docker.io
213+
export DOCKER_REPO ?= siletypesetter/$(_casile)
214+
export DOCKER_TAG ?= HEAD
215+
212216
.PHONY: docker
213217
docker: Dockerfile hooks/build .version
214-
IMAGE_NAME=siletypesetter/$(_casile):HEAD ./hooks/build $(VERSION)
218+
./hooks/build $(VERSION)
219+
docker tag $(DOCKER_REPO):$(DOCKER_TAG) $(DOCKER_REGISTRY)/$(DOCKER_REPO):$(DOCKER_TAG)
220+
221+
222+
.PHONY: docker-build-push
223+
docker-build-push: docker
224+
docker login https://$(DOCKER_REGISTRY) -u $(DOCKER_USERNAME)
225+
docker push $(DOCKER_REGISTRY)/$(DOCKER_REPO):$(DOCKER_TAG)

hooks/build

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ docker build \
2222
--build-arg VCS_REF="${1:-$DESC}" \
2323
--build-arg RUNTIME_DEPS="$RUNTIME_DEPS" \
2424
--build-arg BUILD_DEPS="$BUILD_DEPS" \
25-
--tag $IMAGE_NAME \
25+
--tag $DOCKER_REPO:$DOCKER_TAG \
2626
./

0 commit comments

Comments
 (0)