From 7ed4abf920cdab929e3498175efa514fc7e765e3 Mon Sep 17 00:00:00 2001 From: Julian Skinner Date: Thu, 16 May 2024 13:57:20 -0500 Subject: [PATCH] ci: release-please initial commit (#195) * ci: release-please initial commit * ci: add new label for doc-components * ci: update release-please workflow --- .github/labeler.yml | 5 + .../workflows/actions/publish-npm/action.yml | 2 + .github/workflows/cd.yml | 13 -- .../{release.yml => manual-release.yml} | 10 +- .github/workflows/release-please.yml | 118 ++++++++++++++++++ .../slack_payloads/release-info.json | 37 ++++++ .release-please-manifest.json | 6 + release-please-config.json | 28 +++++ 8 files changed, 197 insertions(+), 22 deletions(-) delete mode 100644 .github/workflows/cd.yml rename .github/workflows/{release.yml => manual-release.yml} (88%) create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/slack_payloads/release-info.json create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/labeler.yml b/.github/labeler.yml index 926a23a8c..7bc571206 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -6,7 +6,12 @@ - changed-files: - any-glob-to-any-file: 'libs/react/**/*' +"package: doc-componenets": +- changed-files: + - any-glob-to-any-file: 'libs/doc-components/**/*' + documentation: +- head-branch: ['docs'] - changed-files: - any-glob-to-any-file: '**/*.[md|mdx]' diff --git a/.github/workflows/actions/publish-npm/action.yml b/.github/workflows/actions/publish-npm/action.yml index 40cda1e89..272f64c54 100644 --- a/.github/workflows/actions/publish-npm/action.yml +++ b/.github/workflows/actions/publish-npm/action.yml @@ -35,10 +35,12 @@ runs: registry-url: 'https://registry.npmjs.org' - name: Install Dependencies + if: inputs.version != '' run: npm ci --legacy-peer-deps --ignore-scripts shell: bash - name: Update Version + if: inputs.version != '' run: npx lerna version ${{ inputs.version }} --yes --exact --no-changelog --no-push --no-git-tag-version --preid=${{ inputs.preid }} shell: bash working-directory: ${{ inputs.working-directory }} diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index ccc513548..000000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Continuous Deployment - -on: - workflow_dispatch: - -jobs: - deploy: - uses: ./.github/workflows/release.yml - with: - preid: '' - ref: 'main' - tag: 'latest' - version: '' diff --git a/.github/workflows/release.yml b/.github/workflows/manual-release.yml similarity index 88% rename from .github/workflows/release.yml rename to .github/workflows/manual-release.yml index e6040ea98..7df572a0c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/manual-release.yml @@ -1,4 +1,4 @@ -name: 'Production Release' +name: 'Manual Production Release' on: workflow_call: @@ -93,11 +93,3 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash - # Lerna does not automatically bump versions - # - name: Bump Package Lock - # run: | - # lerna exec "npm install --package-lock-only" - # git add . - # git commit -m "chore(): update package lock files" - # git push - # shell: bash diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 000000000..4468556bc --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,118 @@ +name: "Release Please" + +on: + push: + branches: + - main + +permissions: + contents: write + id-token: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + paths_released: ${{ steps.manifest-release.outputs.paths_released }} + releases_created: ${{ steps.manifest-release.outputs.releases_created }} + + core--tag_name: ${{ steps.manifest-release.outputs['libs/core--tag_name'] }} + core--version: ${{ steps.manifest-release.outputs['libs/core--version'] }} + core--major: ${{ steps.manifest-release.outputs['libs/core--major'] }} + core--minor: ${{ steps.manifest-release.outputs['libs/core--minor'] }} + core--patch: ${{ steps.manifest-release.outputs['libs/core--patch'] }} + + react--tag_name: ${{ steps.manifest-release.outputs['libs/react--tag_name'] }} + react--version: ${{ steps.manifest-release.outputs['libs/react--version'] }} + react--major: ${{ steps.manifest-release.outputs['libs/react--major'] }} + react--minor: ${{ steps.manifest-release.outputs['libs/react--minor'] }} + react--patch: ${{ steps.manifest-release.outputs['libs/react--patch'] }} + + doc-components--tag_name: ${{ steps.manifest-release.outputs['libs/doc-components--tag_name'] }} + doc-components--version: ${{ steps.manifest-release.outputs['libs/doc-components--version'] }} + doc-components--major: ${{ steps.manifest-release.outputs['libs/doc-components--major'] }} + doc-components--minor: ${{ steps.manifest-release.outputs['libs/doc-components--minor'] }} + doc-components--patch: ${{ steps.manifest-release.outputs['libs/doc-components--patch'] }} + + permissions: + contents: write + id-token: write + pull-requests: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: '' + + - uses: google-github-actions/release-please-action@v4 + id: manifest-release + with: + manifest-file: .release-please-manifest.json + + - name: Show output from Release-Please + run: | + echo "RELEASES_created: ${{ steps.manifest-release.outputs.releases_created }}" + + release-packages: + runs-on: ubuntu-latest + needs: release-please + if: ${{ needs.release-please.outputs.releases_created == 'true' }} + strategy: + matrix: + path: ${{ fromJSON(needs.release-please.outputs.paths_released) }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure user + run: | + git config user.name "DSS Automation Bot" + git config user.email "dev+github-bot@kajabi.com" + + - name: Build Packages + run: npm install --legacy-peer-deps + + - uses: bhowell2/github-substring-action@1.0.2 + id: project-name + with: + value: ${{ matrix.path}} + index_of_str: "libs/" + + - name: Outputs + if: contains(fromJSON(needs.release-please.outputs.paths_released), matrix.path) + run: | + echo "Path Outputs for: ${{ matrix.path}} " + echo "tag_name: ${{ needs.release-please.outputs[format('{0}--tag_name', steps.project-name.outputs.substring)] }}" + echo "version: ${{ needs.release-please.outputs[format('{0}--version', steps.project-name.outputs.substring)] }}" + echo "major: ${{ needs.release-please.outputs[format('{0}--major', steps.project-name.outputs.substring)] }}" + echo "minor: ${{ needs.release-please.outputs[format('{0}--minor', steps.project-name.outputs.substring)] }}" + echo "patch: ${{ needs.release-please.outputs[format('{0}--patch', steps.project-name.outputs.substring)] }}" + + - uses: ./.github/workflows/actions/publish-npm + with: + tag: 'latest' + token: ${{ secrets.NPM_TOKEN }} + working-directory: ${{ matrix.path }} + project: "${{ steps.project-name.outputs.substring }}" + + - name: Current Date + run: | + echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + + - name: Core Slack Notification + if: matrix.path == 'libs/core' && success() + uses: slackapi/slack-github-action@v1.26.0 + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + DATE: ${{ env.CURRENT_DATE }} + RELEASE_URL: "${{ format(vars.release_url, github.repository) }}/${{ needs.release-please.outputs['core--tag_name'] }}" + VERSION: ${{ needs.release-please.outputs['core--version'] }} + with: + channel-id: ${{ vars.SLACK_CHANNEL_NAME }} + payload-file-path: "./.github/workflows/slack_payloads/release-info.json" diff --git a/.github/workflows/slack_payloads/release-info.json b/.github/workflows/slack_payloads/release-info.json new file mode 100644 index 000000000..626df68d0 --- /dev/null +++ b/.github/workflows/slack_payloads/release-info.json @@ -0,0 +1,37 @@ +{ + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": ":pine: Pine Release v${{ env.VERSION }} :pine:" + } + }, + { + "type": "context", + "elements": [ + { + "text": "*${{ env.DATE }}* | Design System Services", + "type": "mrkdwn" + } + ] + }, + { + "type": "divider" + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ":information_source: *Release Information*" + } + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "The details for version *${{ env.VERSION }}* can be found at the link provided below. \n\n ${{ env.RELEASE_URL }}" + } + } + ] +} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 000000000..5f9cf9489 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,6 @@ +{ + "@pine-ds/core": "0.2.4", + "@pine-ds/react": "0.2.4", + "@pine-ds/doc-components": "0.2.4", + ".": "0.0.0" +} diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 000000000..f08da356c --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "bump-minor-pre-major": false, + "bump-patch-for-minor-pre-major": false, + "include-v-in-tag": true, + "packages": { + "libs/core": { + + }, + "libs/doc-components": { + + }, + "libs/react": { + + } + }, + "plugins": [ + "sentence-case" + ], + "changelog-sections": [ + { "type": "feat", "section": "Features 🚀", "hidden": false}, + { "type": "feature", "section": "Features 🚀", "hidden": false }, + { "type": "fix", "section": "Bug Fixes 🐛", "hidden": false}, + { "type": "perf", "section": "Performance Improvements 🛠️", "hidden": false }, + { "type": "revert", "section": "Reverts" }, + { "type": "docs", "section": "Documentation 📄", "hidden": false} + ] +}