From 59e9492fad1e427b911779ea7137e1713d9190c7 Mon Sep 17 00:00:00 2001 From: Kiyana Date: Mon, 26 Feb 2024 13:04:45 +0100 Subject: [PATCH 1/3] SRE-4007 gha for semantic release --- .github/CODEOWNERS | 2 +- .github/common-dependencies/action.yaml | 27 +++++++++++++++ .github/workflows/on-pr-title.yaml | 38 +++++++++++++++++++++ .github/workflows/on-pr.yaml | 28 +++++++++++++++ .github/workflows/on-push.yaml | 45 +++++++++++++++++++++++++ .gitignore | 1 + .releaserc.yaml | 25 ++++++++++++++ CHANGELOG.md | 0 8 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 .github/common-dependencies/action.yaml create mode 100644 .github/workflows/on-pr-title.yaml create mode 100644 .github/workflows/on-pr.yaml create mode 100644 .github/workflows/on-push.yaml create mode 100644 .releaserc.yaml create mode 100644 CHANGELOG.md diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 32c36ee..bef3899 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @StuartApp/sysadmins +* @StuartApp/sre diff --git a/.github/common-dependencies/action.yaml b/.github/common-dependencies/action.yaml new file mode 100644 index 0000000..9f770ea --- /dev/null +++ b/.github/common-dependencies/action.yaml @@ -0,0 +1,27 @@ +--- +name: common-dependencies +description: Set up common workflow dependencies +inputs: + NODEJS_VERSION: + description: Required Workflow Node JS version + required: false + PYTHON_VERSION: + description: Required Workflow Python version + required: false + GO_VERSION: + description: Required Workflow GO version + required: false +runs: + using: composite + steps: + - if: ${{ inputs.NODEJS_VERSION != '' }} + name: Setup NodeJS ${{ inputs.NODEJS_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.NODEJS_VERSION }} + + - if: ${{ inputs.PYTHON_VERSION != '' }} + name: Setup Python ${{ inputs.PYTHON_VERSION }} + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.PYTHON_VERSION }} \ No newline at end of file diff --git a/.github/workflows/on-pr-title.yaml b/.github/workflows/on-pr-title.yaml new file mode 100644 index 0000000..6da32fe --- /dev/null +++ b/.github/workflows/on-pr-title.yaml @@ -0,0 +1,38 @@ +--- +name: Validate PR title + +on: # yamllint disable-line rule:truthy + pull_request: + types: + - opened + - edited + - reopened + - synchronize + +jobs: + pr-title: + name: Validate PR title + runs-on: self-hosted + steps: + - name: Retrieve GitHub event payload + run: echo $GH_EVENT_PAYLOAD + env: + GH_EVENT_PAYLOAD: ${{ toJSON(github.event) }} + - uses: amannn/action-semantic-pull-request@v5.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + fix + feat + docs + ci + chore + requireScope: false + subjectPattern: ^([A-Z]{2,}[0-9]{0,1}-[0-9]+).*$ + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + starts with its associated Jira issue id. + wip: true + validateSingleCommit: false \ No newline at end of file diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml new file mode 100644 index 0000000..04e4197 --- /dev/null +++ b/.github/workflows/on-pr.yaml @@ -0,0 +1,28 @@ +name: Check Pull Request + +on: + pull_request: + branches: + - master +jobs: + release-test: + name: release-test + runs-on: + - self-hosted + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Node.js with GitHub Package Registry + uses: actions/setup-node@v3 + with: + node-version: 20 + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v4 + with: + branch: main + extra_plugins: | + @semantic-release/git + @semantic-release/changelog + dry_run: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/on-push.yaml b/.github/workflows/on-push.yaml new file mode 100644 index 0000000..d311ada --- /dev/null +++ b/.github/workflows/on-push.yaml @@ -0,0 +1,45 @@ +--- +name: Semantic Release + +on: # yamllint disable-line rule:truthy + push: + branches: + - master +env: + NODEJS_VERSION: 16 + +jobs: + semantic-release: + name: Create and Publish Semantic Release + runs-on: self-hosted + outputs: + publish: ${{ steps.semantic-release.outputs.new_release_published }} + version: ${{ steps.semantic-release.outputs.new_release_version }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: ./.github/common-dependencies + with: + NODEJS_VERSION: ${{ env.NODEJS_VERSION }} + + - name: Semantic Release + id: semantic-release + uses: cycjimmy/semantic-release-action@v3 + with: + semantic_version: 19.0.5 + extra_plugins: | + @semantic-release/git@10.0.1 + @semantic-release/changelog@6.0.1 + conventional-changelog-conventionalcommits@4.6.3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_COMMITTER_NAME: ${{ vars.GH_BOT_NAME }} + GIT_AUTHOR_NAME: ${{ vars.GH_BOT_NAME }} + GIT_COMMITTER_EMAIL: ${{ vars.GH_BOT_EMAIL }} + GIT_AUTHOR_EMAIL: ${{ vars.GH_BOT_EMAIL }} + + - name: Print new version + run: echo ${{ steps.semantic-release.outputs.new_release_version }} diff --git a/.gitignore b/.gitignore index 5ae5013..f017eb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.egg-info/ build/ dist/ +.vscode/ \ No newline at end of file diff --git a/.releaserc.yaml b/.releaserc.yaml new file mode 100644 index 0000000..04416e1 --- /dev/null +++ b/.releaserc.yaml @@ -0,0 +1,25 @@ +--- +branches: + - master +ci: false +plugins: + - - "@semantic-release/commit-analyzer" + - preset: conventionalcommits + - - "@semantic-release/release-notes-generator" + - preset: conventionalcommits + - - "@semantic-release/github" + - successComment: >- + 'This PR is included in version ${nextRelease.version} :rocket:' + labels: false + releasedLabels: false + - - "@semantic-release/changelog" + - changelogFile: CHANGELOG.md + changelogTitle: |- + # [CHANGELOG](https://keepachangelog.com/en/1.0.0/) + - - "@semantic-release/git" + - assets: + - CHANGELOG.md + message: |- + chore(release): version ${nextRelease.version} [skip ci] + + ${nextRelease.notes} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 From 983dd118cf78ce37621943b65ebfda2f3e94fcc8 Mon Sep 17 00:00:00 2001 From: Kiyana Date: Mon, 26 Feb 2024 13:06:22 +0100 Subject: [PATCH 2/3] SRE-4007 owner --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index bef3899..89a4683 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @StuartApp/sre +@StuartApp/sre From 617e34f9dcca96828864e668ff424bc61ec88f0e Mon Sep 17 00:00:00 2001 From: Kiyana Date: Mon, 26 Feb 2024 13:07:07 +0100 Subject: [PATCH 3/3] SRE-4007 owner --- .github/workflows/on-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml index 04e4197..ac987d5 100644 --- a/.github/workflows/on-pr.yaml +++ b/.github/workflows/on-pr.yaml @@ -19,7 +19,7 @@ jobs: - name: Semantic Release uses: cycjimmy/semantic-release-action@v4 with: - branch: main + branch: master extra_plugins: | @semantic-release/git @semantic-release/changelog