|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: Version |
| 8 | + required: true |
| 9 | + |
| 10 | +jobs: |
| 11 | + release: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Setup Go |
| 20 | + uses: actions/setup-go@v2 |
| 21 | + with: |
| 22 | + go-version: "1.16.x" |
| 23 | + |
| 24 | + - name: Set up Docker Buildx |
| 25 | + uses: docker/setup-buildx-action@master |
| 26 | + |
| 27 | + - name: Cache |
| 28 | + uses: actions/cache@v2 |
| 29 | + with: |
| 30 | + path: ~/go/pkg/mod |
| 31 | + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 32 | + restore-keys: | |
| 33 | + ${{ runner.os }}-go- |
| 34 | +
|
| 35 | + - name: Login to registry |
| 36 | + uses: docker/login-action@v1 |
| 37 | + with: |
| 38 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 39 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 40 | + |
| 41 | + - name: Tag |
| 42 | + run: | |
| 43 | + git config user.name "$GITHUB_ACTOR" |
| 44 | + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" |
| 45 | + tag='${{ github.event.inputs.version }}' |
| 46 | + git tag --annotate --message "Tag for release $tag" "$tag" |
| 47 | + git push origin "refs/tags/$tag" |
| 48 | +
|
| 49 | + - name: Release |
| 50 | + uses: goreleaser/goreleaser-action@v2 |
| 51 | + with: |
| 52 | + distribution: goreleaser |
| 53 | + version: latest |
| 54 | + args: release --rm-dist |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GH_PAT }} |
| 57 | +# |
| 58 | +# - name: Cache Docker layers |
| 59 | +# uses: actions/cache@v2 |
| 60 | +# with: |
| 61 | +# path: /tmp/.buildx-cache |
| 62 | +# key: ${{ runner.os }}-nginx-errors-buildx |
| 63 | +# |
| 64 | +# - name: Build and push |
| 65 | +# uses: docker/build-push-action@v2 |
| 66 | +# with: |
| 67 | +# context: . |
| 68 | +# push: true |
| 69 | +# labels: | |
| 70 | +# org.label-schema.schema-version=1.0 |
| 71 | +# org.label-schema.version=v${{ github.event.inputs.version }} |
| 72 | +# org.label-schema.name=nginx-errors |
| 73 | +# tags: | |
| 74 | +# vietanhs0817/nginx-errors:v${{ github.event.inputs.version }} |
| 75 | +# vietanhs0817/nginx-errors:latest |
| 76 | +# cache-from: type=local,src=/tmp/.buildx-cache |
| 77 | +# cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 78 | +# |
| 79 | +# - name: Move cache |
| 80 | +# run: | |
| 81 | +# rm -rf /tmp/.buildx-cache |
| 82 | +# mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments