|
1 | 1 | on: |
2 | | - release: |
3 | | - types: [created] |
| 2 | + push: |
| 3 | + tags: |
| 4 | + - 'v*' |
4 | 5 |
|
5 | | -name: Upload release assets after release is created |
| 6 | +name: Upload release assets after tagging |
6 | 7 | jobs: |
7 | 8 | build: |
8 | | - name: build binaries |
| 9 | + name: create assets |
9 | 10 | runs-on: ubuntu-latest |
10 | 11 | steps: |
11 | 12 | - name: Install Go |
12 | 13 | uses: actions/setup-go@v2 |
13 | 14 | with: |
14 | | - go-version: 1.15.x |
| 15 | + go-version: 1.17.x |
15 | 16 | - name: Checkout code |
16 | 17 | uses: actions/checkout@v2 |
17 | | - - name: build |
18 | | - run: | |
19 | | - echo "GO111MODULE=on" >> $GITHUB_ENV |
20 | | - GOOS=windows GOARCH=amd64 go build -o bin/ci-test-windows-amd64.exe |
21 | | - GOOS=linux GOARCH=amd64 go build -o bin/ci-test-linux-amd64 |
22 | | - GOOS=darwin GOARCH=amd64 go build -o bin/ci-test-macos-amd64 |
23 | | - - name: upload artifacts |
24 | | - uses: actions/upload-artifact@master |
| 18 | + - name: Run GoReleaser |
| 19 | + uses: goreleaser/goreleaser-action@v2 |
25 | 20 | with: |
26 | | - name: binaries |
27 | | - path: bin/ |
| 21 | + version: latest |
| 22 | + args: release --rm-dist |
| 23 | + env: |
| 24 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
28 | 25 |
|
29 | | - upload: |
30 | | - name: Upload release assets |
| 26 | + docker-image: |
| 27 | + env: |
| 28 | + REGISTRY: ghcr.io |
| 29 | + IMAGE_NAME: ${{ github.repository }} |
| 30 | + name: create docker image |
31 | 31 | runs-on: ubuntu-latest |
32 | | - needs: [build] |
33 | 32 | steps: |
34 | | - |
35 | | - - name: Branch name |
36 | | - id: branch_name |
37 | | - run: | |
38 | | - echo ::set-output name=SOURCE_NAME::${GITHUB_REF#refs/*/} |
39 | | - echo ::set-output name=SOURCE_BRANCH::${GITHUB_REF#refs/heads/} |
40 | | - echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} |
41 | | -
|
42 | | - - uses: actions/checkout@v1 |
43 | | - |
44 | | - - name: Download build artefacts |
45 | | - uses: actions/download-artifact@v1 |
| 33 | + - name: Checkout code |
| 34 | + uses: actions/checkout@v2 |
| 35 | + - name: Log in to the Container registry |
| 36 | + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 |
46 | 37 | with: |
47 | | - name: binaries |
48 | | - path: bin/ |
| 38 | + registry: ${{ env.REGISTRY }} |
| 39 | + username: ${{ github.actor }} |
| 40 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + - name: build Docker image |
| 42 | + run: | |
| 43 | + VERSION=$(git describe --tags) |
| 44 | + docker build --build-arg "version=$VERSION" --tag ${IMAGE_NAME} . |
49 | 45 |
|
50 | | - - name: Create asset zips |
51 | | - env: |
52 | | - SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} |
| 46 | + - name: push Docker image |
53 | 47 | run: | |
54 | | - mkdir assets |
55 | | - zip assets/ci-test-${SOURCE_TAG}-windows-amd64.zip bin/ci-test-windows-amd64.exe README.md |
56 | | - zip assets/ci-test-${SOURCE_TAG}-linux-amd64.zip bin/ci-test-linux-amd64 README.md |
57 | | - zip assets/ci-test-${SOURCE_TAG}-darwin-amd64.zip bin/ci-test-darwin-amd64 README.md |
58 | | - sha256sum assets/*zip > assets/SHASUMS256.txt |
| 48 | + TAG=$(git describe --tags) |
| 49 | + docker tag ${IMAGE_NAME} ${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA} |
| 50 | + docker tag ${IMAGE_NAME} ${REGISTRY}/${IMAGE_NAME}:${TAG} |
| 51 | + docker tag ${IMAGE_NAME} ${REGISTRY}/${IMAGE_NAME}:latest |
| 52 | + docker push ${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA} |
| 53 | + docker push ${REGISTRY}/${IMAGE_NAME}:${TAG} |
| 54 | + docker push ${REGISTRY}/${IMAGE_NAME}:latest |
59 | 55 |
|
60 | | - - name: Upload release assets |
61 | | - uses: skx/github-action-publish-binaries@master |
62 | | - env: |
63 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
64 | | - with: |
65 | | - args: './assets/*' |
0 commit comments