Skip to content

Commit a30cf1d

Browse files
committedMay 29, 2024·
Update Dockerfile and release stages
1 parent f3fc0c0 commit a30cf1d

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed
 

‎.github/workflows/release.yml

+39-4
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,57 @@ on:
88
permissions:
99
contents: write
1010

11+
env:
12+
IMAGE_NAME: rwp
13+
1114
jobs:
1215
release:
1316
runs-on: [self-hosted, arm64]
1417
steps:
15-
- uses: actions/checkout@v4
18+
- name: Checkout
19+
uses: actions/checkout@v4
1620
with:
1721
fetch-depth: 0
1822
- run: git fetch --force --tags
19-
- uses: actions/setup-go@v5
23+
- name: Set up Go
24+
uses: actions/setup-go@v5
2025
with:
2126
go-version: '>=1.22.0'
22-
- uses: goreleaser/goreleaser-action@v5
27+
- name: Build release
28+
uses: goreleaser/goreleaser-action@v5
2329
with:
2430
distribution: goreleaser
2531
version: latest
2632
args: release --clean
2733
env:
28-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
container:
36+
runs-on: [self-hosted, arm64]
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
- run: git fetch --force --tags
43+
- name: Set up Docker Buildx
44+
uses: docker/setup-buildx-action@v3
45+
- name: Build and push Docker image
46+
run: docker buildx build --platform=linux/amd64,linux/arm64,linux/arm/v7 . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
47+
- name: Log in to registry
48+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
49+
- name: Push image
50+
run: |
51+
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
2952
53+
# This changes all uppercase characters to lowercase.
54+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
55+
# This strips the git ref prefix from the version.
56+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
57+
# This strips the "v" prefix from the tag name.
58+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
59+
# This uses the Docker `latest` tag convention.
60+
[ "$VERSION" == "main" ] && VERSION=latest
61+
echo IMAGE_ID=$IMAGE_ID
62+
echo VERSION=$VERSION
63+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
64+
docker push $IMAGE_ID:$VERSION

‎Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ COPY . ./
2020
# RUN git lfs pull && ls -alh publications
2121

2222
# Run goreleaser
23-
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH goreleaser build --single-target --id rwp --skip=validate --snapshot --output ./rwp
23+
RUN --mount=type=cache,target=/root/.cache/go-build \
24+
--mount=type=cache,target=/go/pkg \
25+
GOOS=$TARGETOS GOARCH=$TARGETARCH goreleaser build --single-target --id rwp --skip=validate --snapshot --output ./rwp
2426

2527
# Run tests
2628
# FROM builder AS tester

0 commit comments

Comments
 (0)
Please sign in to comment.