From 8b034a8f96b745bb7a195a0e892ecda38335d52f Mon Sep 17 00:00:00 2001 From: Aleksander Sadaj Date: Tue, 18 Feb 2025 13:05:47 +0100 Subject: [PATCH 1/2] chore/MSSDK-2108: automated releases github workflows configuration --- .github/labeler.yml | 26 ++++++++++ .github/release-drafter.yml | 52 +++++++++++++++++++ .github/workflows/finalize-release.yml | 44 ++++++++++++++++ .github/workflows/labeler.yml | 12 +++++ .../workflows/pre-release-pull-request.yml | 36 +++++++++++++ .github/workflows/release-drafter.yml | 19 +++++++ 6 files changed, 189 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/finalize-release.yml create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/pre-release-pull-request.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..05f17174 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,26 @@ +breaking: + - head-branch: ['breaking/*', 'breaking-change/*'] + +fix: + - head-branch: ['fix/*'] + +feat: + - head-branch: ['feat/*'] + +chore: + - head-branch: ['chore/*'] + +docs: + - head-branch: ['docs/*'] + +refactor: + - head-branch: ['refactor/*'] + +style: + - head-branch: ['style/*'] + +test: + - head-branch: ['test/*'] + +release: + - head-branch: ['release/*'] diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000..c149951e --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,52 @@ +name-template: '$RESOLVED_VERSION' +tag-template: '$RESOLVED_VERSION' +categories: + - title: 'Breaking changes' + labels: + - 'breaking' + - 'breaking-change' + - title: 'New features' + labels: + - 'feat' + - title: 'Fixes' + labels: + - 'fix' + - title: 'Improvements & Maintenance' + labels: + - 'chore' + - 'docs' + - 'refactor' + - 'style' + - 'test' +version-resolver: + major: + labels: + - 'breaking' + - 'breaking-change' + minor: + labels: + - 'feat' + - 'fix' + patch: + labels: + - 'chore' + - 'docs' + - 'refactor' + - 'style' + - 'test' + default: patch +replacers: + - search: '/(breaking|breaking-change|feat|fix|chore|docs|refactor|style|test)\/MSSDK-\d+:\s*/' + replace: '' +change-template: '- $TITLE ([#$NUMBER]($URL)) by @$AUTHOR' +sort-by: 'title' +template: | + # What's Changed + + $CHANGES + + **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION + +exclude-labels: + - 'skip-changelog' + - 'release' diff --git a/.github/workflows/finalize-release.yml b/.github/workflows/finalize-release.yml new file mode 100644 index 00000000..7750e737 --- /dev/null +++ b/.github/workflows/finalize-release.yml @@ -0,0 +1,44 @@ +name: Finalize release + +on: + release: + types: [published] +permissions: + contents: read +defaults: + run: + shell: bash + +env: + GIT_AUTHOR_NAME: github-actions[bot] + GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com + GIT_COMMITTER_NAME: github-actions[bot] + GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com + +jobs: + publish: + uses: ./.github/workflows/call-publish.yml + permissions: + contents: read + packages: write + with: + access: public + registry: registry.npmjs.org + secrets: + TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} + + merge_main_to_develop: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Merge main into develop + run: | + git fetch origin develop + git fetch origin main + git checkout develop + git merge origin/main + git push origin develop diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000..46cba7f0 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: 'Pull request labeler' +on: + - pull_request_target + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/pre-release-pull-request.yml b/.github/workflows/pre-release-pull-request.yml new file mode 100644 index 00000000..5657f894 --- /dev/null +++ b/.github/workflows/pre-release-pull-request.yml @@ -0,0 +1,36 @@ +name: Pre-release pull request checks + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + branches: + - main + +defaults: + run: + shell: bash + +jobs: + process_release: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + packages: write + outputs: + version: ${{ steps.extract_version.outputs.version }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Check branch name and extract version + id: extract_version + run: | + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" + + if ! [[ $BRANCH_NAME =~ ^(release|hotfix)/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + echo "Error: Branch name must be release/x.y.z or hotfix/x.y.z" && exit 1 + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..44425f3e --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,19 @@ +name: Generate a release draft + +on: + push: + branches: + - main +permissions: + contents: read + +jobs: + generate_release_draft: + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ github.token }} From 7f85f199ffd50f1d60a658f9f103023c6ada7e90 Mon Sep 17 00:00:00 2001 From: Aleksander Sadaj Date: Tue, 18 Feb 2025 15:39:33 +0100 Subject: [PATCH 2/2] chore/MSSDK-2108: polish the workflow configuration files --- .github/workflows/finalize-release.yml | 2 +- .github/workflows/on-release.yml | 17 ----------------- ...=> release-candidate-pull-request-check.yml} | 2 +- 3 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 .github/workflows/on-release.yml rename .github/workflows/{pre-release-pull-request.yml => release-candidate-pull-request-check.yml} (95%) diff --git a/.github/workflows/finalize-release.yml b/.github/workflows/finalize-release.yml index 7750e737..1be24f72 100644 --- a/.github/workflows/finalize-release.yml +++ b/.github/workflows/finalize-release.yml @@ -1,4 +1,4 @@ -name: Finalize release +name: Publish library to NPM registry and synchronize branches on: release: diff --git a/.github/workflows/on-release.yml b/.github/workflows/on-release.yml deleted file mode 100644 index 843b6bf3..00000000 --- a/.github/workflows/on-release.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Publish library on npm registry - -on: - release: - types: [created] - -jobs: - publish: - uses: ./.github/workflows/call-publish.yml - permissions: - contents: read - packages: write - with: - access: public - registry: registry.npmjs.org - secrets: - TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.github/workflows/pre-release-pull-request.yml b/.github/workflows/release-candidate-pull-request-check.yml similarity index 95% rename from .github/workflows/pre-release-pull-request.yml rename to .github/workflows/release-candidate-pull-request-check.yml index 5657f894..fdfdf4b1 100644 --- a/.github/workflows/pre-release-pull-request.yml +++ b/.github/workflows/release-candidate-pull-request-check.yml @@ -1,4 +1,4 @@ -name: Pre-release pull request checks +name: Release candidate Pull Request check on: pull_request: