-
Notifications
You must be signed in to change notification settings - Fork 9
116 lines (102 loc) · 4.01 KB
/
release.yaml
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Release Client
on:
workflow_dispatch:
inputs:
ref:
description: "Git ref to tag and release"
required: true
type: string
default: "main"
releaseLevel:
description: "Release level (major, minor, patch)"
required: true
type: choice
default: "patch"
options:
- "patch" # bug fixes
- "minor" # new features, backwards compatible
- "major" # breaking changes
isPrerelease:
description: "Whether this is a prerelease (alpha / beta) client"
required: true
type: boolean
default: true
prereleaseSuffix:
description: "Suffix to add to version number for marking as a pre-release alpha or beta client. Value ignored when isPrerelease is false"
required: false
type: string
default: ""
jobs:
bump-version-and-release:
runs-on: ubuntu-latest
env:
SEMVER_VERSION: "" # Set by the get_tag_version step
PRERELEASE_SUFFIX: "" # Set by the set_prerelease_suffix step
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.ref }}
- name: Verify prereleaseSuffix not empty if isPrerelease is true
if: ${{ inputs.isPrerelease == true }}
run: |
if [ -z "${{ inputs.prereleaseSuffix }}" ]; then
echo "prereleaseSuffix cannot be empty if isPrerelease is true"
exit 1
fi
- name: Extract current release version through tag and set SEMVER_VERSION
id: get_tag_version
run: |
tag=$(git describe --tags --abbrev=0)
semver=${tag#v} # Remove the 'v' prefix from version number
echo "Current Released Version: $semver"
echo "SEMVER_VERSION=$semver" >> $GITHUB_ENV # Set as environment variable
- name: Set PRERELEASE_SUFFIX if isPrerelease is true
id: set_prerelease_suffix
if: ${{ inputs.isPrerelease == true }}
run: |
echo "PRERELEASE_SUFFIX=${{ inputs.prereleaseSuffix }}" >> $GITHUB_ENV
- name: Bump version
id: bump
uses: "./.github/actions/bump-version"
with:
currentVersion: ${{ env.SEMVER_VERSION}}
bumpType: ${{ inputs.releaseLevel }}
prereleaseSuffix: ${{ env.PRERELEASE_SUFFIX }}
- name: Verify unique release tag
run: |
TAG_NAME=${{ steps.bump.outputs.VERSION_TAG}}
if git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
echo "Tag $TAG_NAME already exists"
exit 1
fi
- name: Update version.go file with new version tag
run: |
echo "Updating version.go file with new version tag"
sed -i "s/Version = \".*\"/Version = \"${{ steps.bump.outputs.VERSION_TAG }}\"/" internal/version.go
- name: Set up Git
run: |
git config --global user.name "Pinecone CI"
git config --global user.email "[email protected]"
- name: Discard changes to version file if prerelease
if: ${{ inputs.isPrerelease == true }}
run: |
git checkout -- internal/version.go
- name: Commit version.go changes if not prerelease
if: ${{ inputs.isPrerelease == false}}
run: |
git add internal/version.go
git commit -m "[skip ci] Bump version to ${{ steps.bump.outputs.VERSION_TAG }}"
- name: Tag version
run: |
newVersionTag="${{ steps.bump.outputs.VERSION_TAG }}"
git tag -a $newVersionTag -m "Release $newVersionTag"
- name: Push tags (prerelease)
if: ${{ inputs.isPrerelease == true }}
# We don't push the version.go for prerelease so the tag wouldn't be pushed
# Push just tags up here in that case since Go releases are handled via git tags
run: git push --tags
- name: Push tags and updated version.go file (production release)
if: ${{ inputs.isPrerelease == false }}
run: git push --follow-tags