|
2 | 2 | name: Release App |
3 | 3 |
|
4 | 4 | on: |
5 | | - release: |
6 | | - types: |
7 | | - - created |
| 5 | + push: |
| 6 | + branches: master |
| 7 | + tags: |
| 8 | + - 'v*.*.*' |
8 | 9 |
|
9 | 10 | jobs: |
10 | | - goreleaser: |
| 11 | + container: |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 | steps: |
13 | 14 | - name: Checkout |
14 | | - uses: actions/checkout@v3 |
15 | | - with: |
16 | | - fetch-depth: 0 |
17 | | - - name: Set up Go |
18 | | - uses: actions/setup-go@v3 |
19 | | - with: |
20 | | - go-version: 1.17.x |
21 | | - - name: Login to GitHub Container Registry |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Set up QEMU |
| 18 | + uses: docker/setup-qemu-action@v1 |
| 19 | + |
| 20 | + - name: Set up Docker Buildx |
| 21 | + uses: docker/setup-buildx-action@v1 |
| 22 | + |
| 23 | + - name: Prepare Image Metadata |
| 24 | + id: prep |
| 25 | + run: | |
| 26 | + DOCKER_IMAGE=ghcr.io/linkyard/cloudscale-slb-controller |
| 27 | + VERSION=noop |
| 28 | + if [ "${{ github.event_name }}" = "schedule" ]; then |
| 29 | + VERSION=nightly |
| 30 | + elif [[ $GITHUB_REF == refs/tags/* ]]; then |
| 31 | + VERSION=${GITHUB_REF#refs/tags/} |
| 32 | + elif [[ $GITHUB_REF == refs/heads/* ]]; then |
| 33 | + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') |
| 34 | + if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then |
| 35 | + VERSION=edge |
| 36 | + fi |
| 37 | + elif [[ $GITHUB_REF == refs/pull/* ]]; then |
| 38 | + VERSION=pr-${{ github.event.number }} |
| 39 | + fi |
| 40 | + TAGS="${DOCKER_IMAGE}:${VERSION}" |
| 41 | + if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then |
| 42 | + MINOR=${VERSION%.*} |
| 43 | + MAJOR=${MINOR%.*} |
| 44 | + TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" |
| 45 | + elif [ "${{ github.event_name }}" = "push" ]; then |
| 46 | + TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" |
| 47 | + fi |
| 48 | + echo ::set-output name=version::${VERSION} |
| 49 | + echo ::set-output name=tags::${TAGS} |
| 50 | + echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 51 | + - name: Login to GHCR |
22 | 52 | uses: docker/login-action@v1 |
23 | | - if: github.event_name != 'pull_request' |
24 | 53 | with: |
25 | 54 | registry: ghcr.io |
26 | | - username: ${{ github.actor }} |
| 55 | + username: ${{ github.repository_owner }} |
27 | 56 | password: ${{ secrets.GITHUB_TOKEN }} |
28 | | - - name: Run GoReleaser |
29 | | - uses: goreleaser/goreleaser-action@v2.9.1 |
| 57 | + |
| 58 | + - name: Build and push |
| 59 | + id: docker_build |
| 60 | + uses: docker/build-push-action@v2 |
30 | 61 | with: |
31 | | - version: latest |
32 | | - args: release --rm-dist |
33 | | - env: |
34 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + context: ./src |
| 63 | + file: ./src/Dockerfile |
| 64 | + push: ${{ github.event_name != 'pull_request' }} |
| 65 | + tags: ${{ steps.prep.outputs.tags }} |
| 66 | + labels: | |
| 67 | + org.opencontainers.image.title=${{ github.event.repository.name }} |
| 68 | + org.opencontainers.image.description=${{ github.event.repository.description }} |
| 69 | + org.opencontainers.image.url=${{ github.event.repository.html_url }} |
| 70 | + org.opencontainers.image.source=${{ github.event.repository.clone_url }} |
| 71 | + org.opencontainers.image.version=${{ steps.prep.outputs.version }} |
| 72 | + org.opencontainers.image.created=${{ steps.prep.outputs.created }} |
| 73 | + org.opencontainers.image.revision=${{ github.sha }} |
| 74 | + org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} |
| 75 | +
|
| 76 | + # goreleaser: |
| 77 | + # runs-on: ubuntu-latest |
| 78 | + # steps: |
| 79 | + # - name: Checkout |
| 80 | + # uses: actions/checkout@v3 |
| 81 | + # with: |
| 82 | + # fetch-depth: 0 |
| 83 | + # - name: Set up Go |
| 84 | + # uses: actions/setup-go@v3 |
| 85 | + # with: |
| 86 | + # go-version: 1.17.x |
| 87 | + # - name: Login to GitHub Container Registry |
| 88 | + # uses: docker/login-action@v1 |
| 89 | + # if: github.event_name != 'pull_request' |
| 90 | + # with: |
| 91 | + # registry: ghcr.io |
| 92 | + # username: ${{ github.actor }} |
| 93 | + # password: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + # - name: Run GoReleaser |
| 95 | + # uses: goreleaser/goreleaser-action@v2.9.1 |
| 96 | + # with: |
| 97 | + # version: latest |
| 98 | + # args: release --rm-dist |
| 99 | + # env: |
| 100 | + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments