From 764cd4ca8a735b4995162c4be8fea57e3dabba81 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Sun, 20 Jul 2025 18:33:01 +0100 Subject: [PATCH 1/7] feat(workflows): dry-run `semantic-release` in GitHub Actions --- .github/workflows/main.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 35696fd3..d4500858 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -98,10 +98,17 @@ jobs: results: name: Release / Collect results permissions: + contents: write + issues: write + pull-requests: write checks: read + container: techneg/ci-semantic-release:v1.0.1 runs-on: ubuntu-latest timeout-minutes: 15 steps: + - run: | # Needed due to bug actions/checkout#2031 + git config --global --add safe.directory "$GITHUB_WORKSPACE" + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # yamllint disable-line rule:line-length - uses: poseidon/wait-for-status-checks@899c768d191b56eef585c18f8558da19e1f3e707 # v0.6.0 with: @@ -114,4 +121,9 @@ jobs: Test / Kitchen (ubuntu-2004-master) ignore_pattern: ^GitLab CI token: ${{ secrets.GITHUB_TOKEN }} + - name: Run `semantic-release` + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + semantic-release --dry-run - run: echo "::notice ::Workflow success!" From 35c2ed6b3da9f04aefec605ee4a05bab9c99ee53 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Sun, 20 Jul 2025 18:44:51 +0100 Subject: [PATCH 2/7] ci(gitlab-ci): switch to image `techneg/ci-semantic-release` --- .github/workflows/main.yml | 2 +- .gitlab-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d4500858..21d010e1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -102,7 +102,7 @@ jobs: issues: write pull-requests: write checks: read - container: techneg/ci-semantic-release:v1.0.1 + container: techneg/ci-semantic-release:v1.1.0 runs-on: ubuntu-latest timeout-minutes: 15 steps: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6b0da106..7bb50f91 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ image_dindrubybionic: &image_dindrubybionic 'techneg/ci-docker-python-ruby:v2.2.65@sha256:64753d90107a81f93ef1827d81f544b689165a9e5efc7494976bb6e11b8bbcc1' image_precommit: &image_precommit 'techneg/ci-pre-commit:v2.4.30@sha256:0d36fff14826b86f7248742a0e8f1d4b4d2341ebb9442dfe1d9c2491b63f3209' image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest@sha256:fe69f9642c7edde46bbd78326d2c42c6e13fc73694efb142e92e206725479328' - image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14@sha256:374f588420087517a3cc0235e11293bffd72d7a59da3d98d5e69f014ff2a7761' + image_semantic-release: &image_semanticrelease 'techneg/ci-semantic-release:v1.1.0' # `services` services_docker_dind: &services_docker_dind - 'docker:28.3.2-dind@sha256:684bc226a69eb91582738f196e59e234355420ee592abea7685e4127afbce645' From e44296e473f142f41c36cecbd252bf172b7174c7 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Sun, 20 Jul 2025 19:01:07 +0100 Subject: [PATCH 3/7] ci(gitlab-ci): remove deprecated keyword `only` for stage `release * `semantic-release` has its own rules around when to release or not, so we can always run the `release` stage and this allows to check that `semantic-release` config is correct --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7bb50f91..30d4406b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -273,7 +273,6 @@ ubuntu-2004-3006-14: {extends: '.test_instance'} # `release` stage: `semantic-release` ############################################################################### semantic-release: - only: *only_branch_master_parent_repo stage: *stage_release image: *image_semanticrelease variables: From bb9320c2ad3caa3cba8442bf261fb09e161c93c2 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Sun, 20 Jul 2025 19:22:32 +0100 Subject: [PATCH 4/7] ci: use upstream `maintainer` with new `ignore` option --- .github/workflows/main.yml | 1 + .gitlab-ci.yml | 2 -- pre-commit_semantic-release.sh | 8 +++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 21d010e1..2a368d55 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -124,6 +124,7 @@ jobs: - name: Run `semantic-release` env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MAINTAINER_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | semantic-release --dry-run - run: echo "::notice ::Workflow success!" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 30d4406b..f19aaea5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -278,7 +278,5 @@ semantic-release: variables: MAINTAINER_TOKEN: '${GH_TOKEN}' script: - # Update `AUTHORS.md` - - '${HOME}/go/bin/maintainer contributor' # Run `semantic-release` - 'semantic-release' diff --git a/pre-commit_semantic-release.sh b/pre-commit_semantic-release.sh index 80f46e20..ad96347b 100755 --- a/pre-commit_semantic-release.sh +++ b/pre-commit_semantic-release.sh @@ -7,7 +7,13 @@ sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA ############################################################################### -# (B) Use `m2r2` to convert automatically produced `.md` docs to `.rst` +# (B) Update `AUTHORS.md` +############################################################################### + +maintainer contributor --ignore-contributors semantic-release-bot,renovate[bot] + +############################################################################### +# (C) Use `m2r2` to convert automatically produced `.md` docs to `.rst` ############################################################################### # Install `m2r2` From 5ffcb684a09a0c97d41fdb11e075f5880d749148 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Mon, 21 Jul 2025 12:13:19 +0100 Subject: [PATCH 5/7] ci(semantic-release): use `m2r` built in to image * which is the Debian packaged `python3-m2r` & `m2r` --- pre-commit_semantic-release.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pre-commit_semantic-release.sh b/pre-commit_semantic-release.sh index ad96347b..f869e2d8 100755 --- a/pre-commit_semantic-release.sh +++ b/pre-commit_semantic-release.sh @@ -3,6 +3,7 @@ ############################################################################### # (A) Update `FORMULA` with `${nextRelease.version}` ############################################################################### + sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA @@ -13,16 +14,13 @@ sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA maintainer contributor --ignore-contributors semantic-release-bot,renovate[bot] ############################################################################### -# (C) Use `m2r2` to convert automatically produced `.md` docs to `.rst` +# (C) Use `m2r` to convert automatically produced `.md` docs to `.rst` ############################################################################### -# Install `m2r2` -pip3 install m2r2 - # Copy and then convert the `.md` docs cp ./*.md docs/ cd docs/ || exit -m2r2 --overwrite ./*.md +m2r --overwrite ./*.md # Change excess `H1` headings to `H2` in converted `CHANGELOG.rst` sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst From dd33d79300956927c281ce69cb6708468e7dc22b Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Mon, 21 Jul 2025 12:16:00 +0100 Subject: [PATCH 6/7] ci(semantic-release): defer to default `branches` values * which now contains `master` and `main` amongst others --- release.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/release.config.js b/release.config.js index 15fa1203..58cac349 100644 --- a/release.config.js +++ b/release.config.js @@ -1,5 +1,4 @@ module.exports = { - branch: 'master', repositoryUrl: 'https://github.com/saltstack-formulas/template-formula', plugins: [ ['@semantic-release/commit-analyzer', { From b8c7f566fa605506eb684139de1947e50c6e354e Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Tue, 22 Jul 2025 01:09:33 +0100 Subject: [PATCH 7/7] ci(semantic-release): config option no longer works --- release.config.js | 85 ++--------------------------------------------- 1 file changed, 2 insertions(+), 83 deletions(-) diff --git a/release.config.js b/release.config.js index 58cac349..937dd03b 100644 --- a/release.config.js +++ b/release.config.js @@ -1,4 +1,5 @@ module.exports = { + // TODO: remove this when we no longer process releases on GitLab CI repositoryUrl: 'https://github.com/saltstack-formulas/template-formula', plugins: [ ['@semantic-release/commit-analyzer', { @@ -20,88 +21,6 @@ module.exports = { '@semantic-release/github' ], generateNotes: { - preset: 'angular', - writerOpts: { - // Required due to upstream bug preventing all types being displayed. - // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317 - // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410 - transform: (commit, context) => { - const issues = [] - - commit.notes.forEach(note => { - note.title = 'BREAKING CHANGES' - }) - - // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. - if (commit.type === 'feat') { - commit.type = 'Features' - } else if (commit.type === 'fix') { - commit.type = 'Bug Fixes' - } else if (commit.type === 'perf') { - commit.type = 'Performance Improvements' - } else if (commit.type === 'revert') { - commit.type = 'Reverts' - } else if (commit.type === 'docs') { - commit.type = 'Documentation' - } else if (commit.type === 'style') { - commit.type = 'Styles' - } else if (commit.type === 'refactor') { - commit.type = 'Code Refactoring' - } else if (commit.type === 'test') { - commit.type = 'Tests' - } else if (commit.type === 'build') { - commit.type = 'Build System' - // } else if (commit.type === `chore`) { - // commit.type = `Maintenance` - } else if (commit.type === 'ci') { - commit.type = 'Continuous Integration' - } else { - return - } - - if (commit.scope === '*') { - commit.scope = '' - } - - if (typeof commit.hash === 'string') { - commit.shortHash = commit.hash.substring(0, 7) - } - - if (typeof commit.subject === 'string') { - let url = context.repository - ? `${context.host}/${context.owner}/${context.repository}` - : context.repoUrl - if (url) { - url = `${url}/issues/` - // Issue URLs. - commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { - issues.push(issue) - return `[#${issue}](${url}${issue})` - }) - } - if (context.host) { - // User URLs. - commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => { - if (username.includes('/')) { - return `@${username}` - } - - return `[@${username}](${context.host}/${username})` - }) - } - } - - // remove references that already appear in the subject - commit.references = commit.references.filter(reference => { - if (issues.indexOf(reference.issue) === -1) { - return true - } - - return false - }) - - return commit - } - } + preset: 'angular' } }