|
8 | 8 | permissions:
|
9 | 9 | contents: write
|
10 | 10 |
|
| 11 | +env: |
| 12 | + IMAGE_NAME: rwp |
| 13 | + |
11 | 14 | jobs:
|
12 | 15 | release:
|
13 | 16 | runs-on: [self-hosted, arm64]
|
14 | 17 | steps:
|
15 |
| - - uses: actions/checkout@v4 |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v4 |
16 | 20 | with:
|
17 | 21 | fetch-depth: 0
|
18 | 22 | - run: git fetch --force --tags
|
19 |
| - - uses: actions/setup-go@v5 |
| 23 | + - name: Set up Go |
| 24 | + uses: actions/setup-go@v5 |
20 | 25 | with:
|
21 | 26 | go-version: '>=1.22.0'
|
22 |
| - - uses: goreleaser/goreleaser-action@v5 |
| 27 | + - name: Build release |
| 28 | + uses: goreleaser/goreleaser-action@v5 |
23 | 29 | with:
|
24 | 30 | distribution: goreleaser
|
25 | 31 | version: latest
|
26 | 32 | args: release --clean
|
27 | 33 | 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 |
29 | 52 |
|
| 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 |
0 commit comments