Release PowerShell SDK (auto) #105
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |