|
| 1 | +name: Manual Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump: |
| 7 | + description: 'Version bump type (used if release_version is empty)' |
| 8 | + type: choice |
| 9 | + options: |
| 10 | + - major |
| 11 | + - minor |
| 12 | + - patch |
| 13 | + - prerelease |
| 14 | + required: false |
| 15 | + release_version: |
| 16 | + description: 'Semver version to release (must be > current root version)' |
| 17 | + required: false |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + pull-requests: write |
| 22 | + id-token: write |
| 23 | + packages: write |
| 24 | + |
| 25 | +jobs: |
| 26 | + release: |
| 27 | + # Allow only on master, spring*, summer*, winter*; |
| 28 | + if: ${{ github.repository_owner == 'salesforce' && (github.ref_name == 'master' || startsWith(github.ref_name, 'spring') || startsWith(github.ref_name, 'summer') || startsWith(github.ref_name, 'winter')) }} |
| 29 | + environment: release |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Setup Node |
| 38 | + uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: '20' |
| 41 | + registry-url: 'https://registry.npmjs.org' |
| 42 | + cache: 'yarn' |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: yarn install --frozen-lockfile |
| 46 | + |
| 47 | + - name: Resolve version input |
| 48 | + id: resolve_version |
| 49 | + run: | |
| 50 | + RELEASE_VERSION='${{ inputs.release_version }}' |
| 51 | + if [ -z "$RELEASE_VERSION" ]; then |
| 52 | + RELEASE_VERSION='${{ inputs.bump }}' |
| 53 | + fi |
| 54 | + echo "resolved=$RELEASE_VERSION" >> "$GITHUB_OUTPUT" |
| 55 | +
|
| 56 | + - name: Bump versions and commit |
| 57 | + env: |
| 58 | + INPUT_VERSION: ${{ steps.resolve_version.outputs.resolved }} |
| 59 | + run: | |
| 60 | + git config user.name "github-actions[bot]" |
| 61 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 62 | + node ./scripts/release/version.js "$INPUT_VERSION" |
| 63 | + RESOLVED_VERSION=$(jq -r .version package.json) |
| 64 | + git commit -am "chore: release v$RESOLVED_VERSION" |
| 65 | + git push origin HEAD |
| 66 | +
|
| 67 | + - name: Build |
| 68 | + run: yarn build |
| 69 | + |
| 70 | + - name: Tag and create GitHub release |
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + run: | |
| 74 | + VERSION=$(jq -r .version package.json) |
| 75 | + git tag -a "v$VERSION" -m "Release v$VERSION" |
| 76 | + git push origin tag "v$VERSION" |
| 77 | + gh release create "v$VERSION" --title "v$VERSION" --generate-notes |
| 78 | +
|
| 79 | + - name: Publish to npm |
| 80 | + env: |
| 81 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 82 | + run: | |
| 83 | + TAG=$([ "$GITHUB_REF_NAME" = "master" ] && echo latest || echo "$GITHUB_REF_NAME") |
| 84 | + yarn nx release publish --yes --registry https://registry.npmjs.org --tag "$TAG" |
0 commit comments