-
Notifications
You must be signed in to change notification settings - Fork 24
169 lines (146 loc) · 6.02 KB
/
Copy pathrelease.yaml
File metadata and controls
169 lines (146 loc) · 6.02 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: "Release PowerShell SDK"
run-name: >-
${{
github.event_name == 'workflow_dispatch' && github.event.inputs.version != ''
&& format('Release PowerShell SDK v{0}', github.event.inputs.version)
|| 'Release PowerShell SDK (auto)'
}}
on:
workflow_dispatch:
inputs:
version:
description: "The version to release (e.g. 1.8.0). Leave empty to auto-increment patch."
required: false
schedule:
- cron: "0 8 * * 1-5"
concurrency:
group: release-${{ github.repository }}
cancel-in-progress: false
env:
SAIL_CLIENT_ID: ${{ secrets.SDK_TEST_TENANT_CLIENT_ID }}
SAIL_CLIENT_SECRET: ${{ secrets.SDK_TEST_TENANT_CLIENT_SECRET }}
SAIL_BASE_URL: ${{ secrets.SDK_TEST_TENANT_BASE_URL }}
jobs:
check-changes:
name: Check for spec changes
runs-on: ubuntu-latest
outputs:
proceed: ${{ steps.check.outputs.proceed }}
steps:
- name: Checkout SDK
if: github.event_name == 'schedule'
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Checkout API Specs
if: github.event_name == 'schedule'
uses: actions/checkout@v6
with:
repository: sailpoint-oss/api-specs
path: api-specs
ref: main
- name: Determine whether to proceed
id: check
shell: bash
run: |
if [ "${{ github.event_name }}" != "schedule" ]; then
echo "proceed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "v0.0.0")
TAG_DATE=$(git log -1 --format=%aI "$LATEST_TAG" 2>/dev/null || echo "1970-01-01")
TAG_COMMIT=$(cd api-specs && git rev-list -1 --before="$TAG_DATE" HEAD 2>/dev/null || echo "")
if [ -z "$TAG_COMMIT" ]; then
echo "Could not find api-specs commit at tag date. Proceeding to be safe."
echo "proceed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
SPEC_CHANGES=$(cd api-specs && git diff --name-only "$TAG_COMMIT" HEAD -- 'idn/**/*.yaml' | wc -l)
if [ "$SPEC_CHANGES" -eq 0 ]; then
echo "No spec file changes since $LATEST_TAG ($TAG_DATE). Skipping release."
echo "proceed=false" >> "$GITHUB_OUTPUT"
else
echo "Found $SPEC_CHANGES spec file(s) changed since $LATEST_TAG. Proceeding."
echo "proceed=true" >> "$GITHUB_OUTPUT"
fi
release:
name: Release PowerShell SDK
needs: check-changes
if: needs.check-changes.outputs.proceed == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: main
fetch-depth: 0
token: ${{ secrets.DEVREL_SERVICE_TOKEN }}
- name: Checkout API Specs
uses: actions/checkout@v6
with:
repository: sailpoint-oss/api-specs
path: api-specs
ref: main
- name: Set up yq
uses: frenck/action-setup-yq@v1
- name: Determine version
id: version
shell: bash
run: |
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null || echo "v0.0.0")
LATEST_VERSION="${LATEST_TAG#v}"
echo "latest=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
if [ -n "${{ github.event.inputs.version }}" ]; then
NEW_VERSION="${{ github.event.inputs.version }}"
else
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION"
PATCH=$((PATCH + 1))
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
fi
function ver { printf "%03d%03d%03d%03d" $(echo "$1" | tr '.' ' '); }
if [ "$(ver "$LATEST_VERSION")" -ge "$(ver "$NEW_VERSION")" ]; then
echo "::error::New version $NEW_VERSION is not greater than current version $LATEST_VERSION"
exit 1
fi
echo "new=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "Releasing version $NEW_VERSION (previous: $LATEST_VERSION)"
- name: Update config files with new version
shell: bash
run: |
VERSION="${{ steps.version.outputs.new }}"
yq -i ".packageVersion = \"$VERSION\"" sdk-resources/v3-config.yaml
yq -i ".packageVersion = \"$VERSION\"" sdk-resources/beta-config.yaml
yq -i ".packageVersion = \"$VERSION\"" sdk-resources/v2024-config.yaml
yq -i ".packageVersion = \"$VERSION\"" sdk-resources/v2025-config.yaml
yq -i ".packageVersion = \"$VERSION\"" sdk-resources/v2026-config.yaml
yq -i ".packageVersion = \"$VERSION\"" sdk-resources/nerm-config.yaml
yq -i ".packageVersion = \"$VERSION\"" sdk-resources/v2025-nerm-config.yaml
- name: Update Build.ps1 ModuleVersion
shell: bash
run: |
LATEST="${{ steps.version.outputs.latest }}"
NEW="${{ steps.version.outputs.new }}"
LATEST_ESCAPED="${LATEST//./\\.}"
cd PSSailpoint
sed -e "s/ModuleVersion = '${LATEST_ESCAPED}'/ModuleVersion = '${NEW}'/g" Build.ps1 > Build.ps1.tmp && mv Build.ps1.tmp Build.ps1
sed -e "s/RequiredVersion = '${LATEST_ESCAPED}'/RequiredVersion = '${NEW}'/g" Build.ps1 > Build.ps1.tmp && mv Build.ps1.tmp Build.ps1
- name: Build SDK
uses: ./.github/actions/build-sdk
- name: Commit changes and tag
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: "Bump version to v${{ steps.version.outputs.new }}"
tagging_message: "v${{ steps.version.outputs.new }}"
commit_user_name: developer-relations-sp
commit_user_email: devrel-service@sailpoint.com
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.DEVREL_SERVICE_TOKEN }}
tag_name: "v${{ steps.version.outputs.new }}"
name: "v${{ steps.version.outputs.new }}"
draft: false
prerelease: false
generate_release_notes: true