Skip to content

Commit ebd1e63

Browse files
feat(.github): use docker/metadata-action to generate tags and use cache for apk on build (#340)
* chore: mount instead of copy Signed-off-by: KeisukeYamashita <[email protected]> * feat: release vx and vxy version along with the release Signed-off-by: KeisukeYamashita <[email protected]> --------- Signed-off-by: KeisukeYamashita <[email protected]>
1 parent 31a167d commit ebd1e63

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

.github/workflows/release.yaml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,31 +87,34 @@ jobs:
8787
docker:
8888
runs-on: ubuntu-latest
8989
environment: docker
90-
needs:
91-
- info
9290
steps:
9391
- uses: docker/setup-qemu-action@v3
92+
9493
- uses: docker/setup-buildx-action@v3
94+
9595
- uses: docker/login-action@v3
9696
with:
9797
username: ${{ secrets.DOCKERHUB_USERNAME }}
9898
password: ${{ secrets.DOCKERHUB_TOKEN }}
99+
100+
- uses: docker/metadata-action@v5
101+
id: meta
102+
with:
103+
images: 1915keke/commitlint-rs
104+
tags: |
105+
type=raw,value=latest
106+
type=semver,pattern={{version}}
107+
type=semver,pattern={{major}}.{{minor}}
108+
type=semver,pattern={{major}}
109+
99110
- uses: docker/build-push-action@v6
100111
with:
101112
platforms: linux/amd64,linux/arm64
102113
push: true
103-
tags: 1915keke/commitlint-rs:${{ needs.info.outputs.tag }}
114+
tags: ${{ steps.meta.outputs.tags }}
104115
cache-from: type=gha
105116
cache-to: type=gha,mode=max
106117

107-
info:
108-
runs-on: ubuntu-latest
109-
outputs:
110-
tag: ${{ steps.info.outputs.tag }}
111-
steps:
112-
- id: info
113-
run: echo tag=$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/v//') >> $GITHUB_OUTPUT
114-
115118
publish:
116119
runs-on: ubuntu-latest
117120
needs:

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
FROM rust:1.80-alpine as builder
22
WORKDIR /app
33

4-
RUN apk update \
4+
RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \
5+
apk update \
56
&& apk add --no-cache musl-dev
67

7-
RUN --mount=type=bind,target=. cargo install --path .
8+
COPY . .
9+
RUN cargo install --path .
810

911
FROM alpine
1012
LABEL maintainer="KeisukeYamashita <[email protected]>"
1113

12-
RUN apk update \
14+
RUN --mount=type=cache,target=/var/cache/apk,sharing=locked \
15+
apk update \
1316
&& apk add --no-cache musl-dev
1417

1518
COPY --from=builder /usr/local/cargo/bin/commitlint /usr/local/bin/commitlint

0 commit comments

Comments
 (0)