-
Notifications
You must be signed in to change notification settings - Fork 7
93 lines (79 loc) · 2.82 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
82
83
84
85
86
87
88
89
90
91
92
93
name: Release
on:
workflow_dispatch:
inputs:
packageVersion:
description: "The version to publish (patch, minor, current)"
required: true
dryRun:
description: "Do a dry run to preview instead of a real release (true/false)"
required: true
default: "true"
permissions:
contents: write
jobs:
authorize:
name: Authorize
runs-on: ubuntu-latest
steps:
- name: ${{ github.actor }} permission check to do a release
uses: "lannonbr/[email protected]"
with:
permission: "write"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release:
name: Release
runs-on: ubuntu-latest
needs: [authorize]
steps:
- name: Checkout for ${{ github.event.inputs.dryRun != 'false' && 'dry run' || 'PRODUCTION RELEASE' }}
uses: actions/checkout@v3
with:
fetch-depth: 0
ssh-key: ${{ secrets.SSH_DEPLOY_KEY }}
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '>=1.17'
cache: true
- name: Run tests
run: go test -v ./...
- name: Get new version
id: new_version
uses: anothrNick/[email protected]
if: ${{ github.event.inputs.packageVersion != 'current' }}
env:
DRY_RUN: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WITH_V: false
DEFAULT_BUMP: ${{ github.event.inputs.packageVersion }}
- name: Configure Git User
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Update SdkVersion in constants.go
if: ${{ github.event.inputs.packageVersion != 'current' }}
run: |
sed -i -e 's/\(SdkVersion\s*=\s*\)"[^"]*"/\1"${{ steps.new_version.outputs.new_tag }}"/' ./amplitude/constants/constants.go
git commit -am "v${{ steps.new_version.outputs.new_tag }}"
- name: Create version tag
if: ${{ github.event.inputs.packageVersion != 'current' }}
run: |
git tag "v${{ steps.new_version.outputs.new_tag }}"
- name: Push Git changes
if: ${{ github.event.inputs.packageVersion != 'current' && github.event.inputs.dryRun == 'false' }}
run: |
git push
git push --tags
- name: Release version
if: ${{ github.event.inputs.dryRun == 'false' }}
uses: goreleaser/goreleaser-action@v4
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update Go Module Index
if: ${{ github.event.inputs.dryRun == 'false' }}
run: curl "https://proxy.golang.org/github.com/amplitude/analytics-go/@v/$(git describe HEAD --tags --abbrev=0).info"