-
Notifications
You must be signed in to change notification settings - Fork 13
81 lines (72 loc) · 2.37 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Create Release
on:
workflow_call:
inputs:
version:
description: The semantic tag version against which the release will be created
required: true
type: string
secrets:
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
push:
tags:
- v*
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 ## Required for goreleaser - https://goreleaser.com/ci/actions/#usage
- name: Extract Current Tag
run: |
current=${GITHUB_REF#refs/tags/}
if [[ -n $CURRENT_TAG ]]; then
current=$CURRENT_TAG
fi
echo "::set-output name=tag::$current"
id: current-tag
env:
CURRENT_TAG: ${{ inputs.version }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Create Github Release
uses: goreleaser/goreleaser-action@v5
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
push: true
tags: |
mercari/spanner-autoscaler:latest
mercari/spanner-autoscaler:${{ steps.current-tag.outputs.tag }}
- name: Get Merged Pull Request
uses: actions-ecosystem/action-get-merged-pull-request@v1
id: get-merged-pull-request
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Comment on Pull Request
uses: actions-ecosystem/action-create-comment@v1
if: ${{ steps.get-merged-pull-request.outputs.number != null }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.get-merged-pull-request.outputs.number }}
body: |
A new github release with version [${{ steps.current-tag.outputs.tag }}](https://github.com/${{ github.repository }}/releases/tag/${{ steps.current-tag.outputs.tag }}) has been created! :tada: