From af3a3dd39974f95d27a27b056c238ff525ec66e9 Mon Sep 17 00:00:00 2001 From: Aleksander Sadaj Date: Wed, 19 Feb 2025 11:01:31 +0100 Subject: [PATCH] chore/MSSDK-2108: automated releases github workflows configuration (#463) * chore/MSSDK-2108: automated releases github workflows configuration * chore/MSSDK-2108: polish the workflow configuration files --- .github/labeler.yml | 26 ++++++++++ .github/release-drafter.yml | 52 +++++++++++++++++++ .github/workflows/finalize-release.yml | 44 ++++++++++++++++ .github/workflows/labeler.yml | 12 +++++ .github/workflows/on-release.yml | 17 ------ .../release-candidate-pull-request-check.yml | 36 +++++++++++++ .github/workflows/release-drafter.yml | 19 +++++++ 7 files changed, 189 insertions(+), 17 deletions(-) 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 delete mode 100644 .github/workflows/on-release.yml create mode 100644 .github/workflows/release-candidate-pull-request-check.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 000000000..05f17174f --- /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 000000000..c149951ef --- /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 000000000..1be24f727 --- /dev/null +++ b/.github/workflows/finalize-release.yml @@ -0,0 +1,44 @@ +name: Publish library to NPM registry and synchronize branches + +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 000000000..46cba7f05 --- /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/on-release.yml b/.github/workflows/on-release.yml deleted file mode 100644 index 843b6bf39..000000000 --- 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/release-candidate-pull-request-check.yml b/.github/workflows/release-candidate-pull-request-check.yml new file mode 100644 index 000000000..fdfdf4b14 --- /dev/null +++ b/.github/workflows/release-candidate-pull-request-check.yml @@ -0,0 +1,36 @@ +name: Release candidate Pull Request check + +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 000000000..44425f3ed --- /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 }}