Release #9
Workflow file for this run
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - force-app | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Version Number (#.#.#) | |
| required: false | |
| type: string | |
| concurrency: | |
| # Queue releases to prevent version collisions - don't cancel, let them run sequentially | |
| group: release-${{ github.repository }} | |
| cancel-in-progress: false | |
| jobs: | |
| versioning: | |
| name: Versioning | |
| outputs: | |
| version-number: ${{ steps.determine-version.outputs.version-number }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Did sfdx-project.json Change? | |
| if: ${{ github.event_name == 'push' }} | |
| id: check-changes | |
| run: | | |
| # Check if sfdx-project.json was modified in the latest commit | |
| if git diff --name-only HEAD~1 HEAD | grep -q "^sfdx-project.json$"; then | |
| echo "sfdx-project.json was modified" | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "sfdx-project.json was not modified" | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Determine Version | |
| id: determine-version | |
| run: | | |
| # Get current version from sfdx-project.json: | |
| CURRENT_VERSION=$(jq -r '.packageDirectories[] | select(.default == true) | .versionNumber' sfdx-project.json | sed 's/\.NEXT$//') | |
| echo "Current version: $CURRENT_VERSION" | |
| if [[ "${{ github.event_name }}" == "push" && "${{ steps.check-changes.outputs.changed }}" == "false" ]]; then | |
| # 1. On push AND sfdx-project.json was NOT updated - increment the version | |
| IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" | |
| MAJOR=${VERSION_PARTS[0]} | |
| MINOR=${VERSION_PARTS[1]} | |
| PATCH=${VERSION_PARTS[2]} | |
| NEW_PATCH=$((PATCH + 1)) | |
| NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" | |
| echo "Auto-incremented version to: $NEW_VERSION" | |
| elif [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.version }}" ]]; then | |
| # 2. On workflow dispatch & a version input is provided - use the version input | |
| NEW_VERSION="${{ inputs.version }}" | |
| echo "Using input version: $NEW_VERSION" | |
| else | |
| # 3. Else - use the existing version number | |
| NEW_VERSION="$CURRENT_VERSION" | |
| echo "Using current version: $NEW_VERSION" | |
| fi | |
| echo "version-number=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Validate Package Version | |
| env: | |
| VERSION: ${{ steps.determine-version.outputs.version-number }} | |
| run: | | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "ERROR: Version '$VERSION' is not valid semver format. Expected 'MAJOR.MINOR.PATCH'" | |
| exit 1 | |
| fi | |
| create-managed-package-version: | |
| name: Create Managed Package Version | |
| needs: versioning | |
| permissions: | |
| contents: write | |
| uses: ./.github/workflows/packaging.yml | |
| secrets: inherit | |
| with: | |
| package: managed | |
| version: ${{ needs.versioning.outputs.version-number }} | |
| create-unlocked-package-version: | |
| name: Create Unlocked Package Version | |
| needs: [versioning, create-managed-package-version] | |
| permissions: | |
| contents: write | |
| uses: ./.github/workflows/packaging.yml | |
| secrets: inherit | |
| with: | |
| package: unlocked | |
| version: ${{ needs.versioning.outputs.version-number }} | |
| create-release: | |
| name: Create Release | |
| needs: [versioning, create-managed-package-version, create-unlocked-package-version] | |
| if: ${{ success() && needs.create-managed-package-version.outputs.version-id != '' && needs.create-unlocked-package-version.outputs.version-id != '' }} | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Draft Release Body | |
| id: release-body | |
| run: | | |
| VERSION="${{ needs.versioning.outputs.version-number }}" | |
| MANAGED_ID="${{ needs.create-managed-package-version.outputs.version-id }}" | |
| UNLOCKED_ID="${{ needs.create-unlocked-package-version.outputs.version-id }}" | |
| # Start building release body | |
| { | |
| echo "## Installation" | |
| echo "" | |
| echo "### Managed Package" | |
| echo "**Package Version**: \`$MANAGED_ID\`" | |
| echo "\`\`\`bash" | |
| echo "sf package install --package $MANAGED_ID --wait 20" | |
| echo "\`\`\`" | |
| echo "" | |
| echo "### Unlocked Package" | |
| echo "**Package Version**: \`$UNLOCKED_ID\`" | |
| echo "\`\`\`bash" | |
| echo "sf package install --package $UNLOCKED_ID --wait 20" | |
| echo "\`\`\`" | |
| echo "" | |
| } > release_body.md | |
| # Set as output for next step | |
| { | |
| echo 'body<<EOF' | |
| cat release_body.md | |
| echo 'EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2.3.2 | |
| with: | |
| body: ${{ steps.release-body.outputs.body }} | |
| generate_release_notes: true | |
| make_latest: true | |
| tag_name: v${{ needs.versioning.outputs.version-number }} | |
| token: ${{ secrets.GITHUB_TOKEN }} |