Skip to content

Commit 79d81d5

Browse files
authored
Merge pull request #352 from dafyddj/ci/sem-rel-dry-run
ci: move towards releasing using GitHub Actions
2 parents bc3d31b + b8c7f56 commit 79d81d5

4 files changed

Lines changed: 24 additions & 92 deletions

File tree

.github/workflows/main.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,17 @@ jobs:
9898
results:
9999
name: Release / Collect results
100100
permissions:
101+
contents: write
102+
issues: write
103+
pull-requests: write
101104
checks: read
105+
container: techneg/ci-semantic-release:v1.1.0
102106
runs-on: ubuntu-latest
103107
timeout-minutes: 15
104108
steps:
109+
- run: | # Needed due to bug actions/checkout#2031
110+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
111+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
105112
# yamllint disable-line rule:line-length
106113
- uses: poseidon/wait-for-status-checks@899c768d191b56eef585c18f8558da19e1f3e707 # v0.6.0
107114
with:
@@ -114,4 +121,10 @@ jobs:
114121
Test / Kitchen (ubuntu-2004-master)
115122
ignore_pattern: ^GitLab CI
116123
token: ${{ secrets.GITHUB_TOKEN }}
124+
- name: Run `semantic-release`
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
MAINTAINER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
run: |
129+
semantic-release --dry-run
117130
- run: echo "::notice ::Workflow success!"

.gitlab-ci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
image_dindrubybionic: &image_dindrubybionic 'techneg/ci-docker-python-ruby:v2.2.67@sha256:2887fb02ee694a97241777b043b1942b7e6803080e06dd18633f083eed463844'
2121
image_precommit: &image_precommit 'techneg/ci-pre-commit:v2.4.32@sha256:fa9eef397583add95f4fccefa6ecbbf7a3845d6168f07393da7bc619696b246b'
2222
image_rubocop: &image_rubocop 'pipelinecomponents/rubocop:latest@sha256:fe69f9642c7edde46bbd78326d2c42c6e13fc73694efb142e92e206725479328'
23-
image_semantic-release: &image_semanticrelease 'myii/ssf-semantic-release:15.14@sha256:374f588420087517a3cc0235e11293bffd72d7a59da3d98d5e69f014ff2a7761'
23+
image_semantic-release: &image_semanticrelease 'techneg/ci-semantic-release:v1.1.0'
2424
# `services`
2525
services_docker_dind: &services_docker_dind
2626
- 'docker:28.3.2-dind@sha256:44383404ebf0c36243f5969f0dddd23c204ea3bb185e7473a4141f6ccfd07b53'
@@ -273,13 +273,10 @@ ubuntu-2004-3006-14: {extends: '.test_instance'}
273273
# `release` stage: `semantic-release`
274274
###############################################################################
275275
semantic-release:
276-
only: *only_branch_master_parent_repo
277276
stage: *stage_release
278277
image: *image_semanticrelease
279278
variables:
280279
MAINTAINER_TOKEN: '${GH_TOKEN}'
281280
script:
282-
# Update `AUTHORS.md`
283-
- '${HOME}/go/bin/maintainer contributor'
284281
# Run `semantic-release`
285282
- 'semantic-release'

pre-commit_semantic-release.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@
33
###############################################################################
44
# (A) Update `FORMULA` with `${nextRelease.version}`
55
###############################################################################
6+
67
sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA
78

89

910
###############################################################################
10-
# (B) Use `m2r2` to convert automatically produced `.md` docs to `.rst`
11+
# (B) Update `AUTHORS.md`
1112
###############################################################################
1213

13-
# Install `m2r2`
14-
pip3 install m2r2
14+
maintainer contributor --ignore-contributors semantic-release-bot,renovate[bot]
15+
16+
###############################################################################
17+
# (C) Use `m2r` to convert automatically produced `.md` docs to `.rst`
18+
###############################################################################
1519

1620
# Copy and then convert the `.md` docs
1721
cp ./*.md docs/
1822
cd docs/ || exit
19-
m2r2 --overwrite ./*.md
23+
m2r --overwrite ./*.md
2024

2125
# Change excess `H1` headings to `H2` in converted `CHANGELOG.rst`
2226
sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst

release.config.js

Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
branch: 'master',
2+
// TODO: remove this when we no longer process releases on GitLab CI
33
repositoryUrl: 'https://github.com/saltstack-formulas/template-formula',
44
plugins: [
55
['@semantic-release/commit-analyzer', {
@@ -21,88 +21,6 @@ module.exports = {
2121
'@semantic-release/github'
2222
],
2323
generateNotes: {
24-
preset: 'angular',
25-
writerOpts: {
26-
// Required due to upstream bug preventing all types being displayed.
27-
// Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317
28-
// Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410
29-
transform: (commit, context) => {
30-
const issues = []
31-
32-
commit.notes.forEach(note => {
33-
note.title = 'BREAKING CHANGES'
34-
})
35-
36-
// NOTE: Any changes here must be reflected in `CONTRIBUTING.md`.
37-
if (commit.type === 'feat') {
38-
commit.type = 'Features'
39-
} else if (commit.type === 'fix') {
40-
commit.type = 'Bug Fixes'
41-
} else if (commit.type === 'perf') {
42-
commit.type = 'Performance Improvements'
43-
} else if (commit.type === 'revert') {
44-
commit.type = 'Reverts'
45-
} else if (commit.type === 'docs') {
46-
commit.type = 'Documentation'
47-
} else if (commit.type === 'style') {
48-
commit.type = 'Styles'
49-
} else if (commit.type === 'refactor') {
50-
commit.type = 'Code Refactoring'
51-
} else if (commit.type === 'test') {
52-
commit.type = 'Tests'
53-
} else if (commit.type === 'build') {
54-
commit.type = 'Build System'
55-
// } else if (commit.type === `chore`) {
56-
// commit.type = `Maintenance`
57-
} else if (commit.type === 'ci') {
58-
commit.type = 'Continuous Integration'
59-
} else {
60-
return
61-
}
62-
63-
if (commit.scope === '*') {
64-
commit.scope = ''
65-
}
66-
67-
if (typeof commit.hash === 'string') {
68-
commit.shortHash = commit.hash.substring(0, 7)
69-
}
70-
71-
if (typeof commit.subject === 'string') {
72-
let url = context.repository
73-
? `${context.host}/${context.owner}/${context.repository}`
74-
: context.repoUrl
75-
if (url) {
76-
url = `${url}/issues/`
77-
// Issue URLs.
78-
commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => {
79-
issues.push(issue)
80-
return `[#${issue}](${url}${issue})`
81-
})
82-
}
83-
if (context.host) {
84-
// User URLs.
85-
commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
86-
if (username.includes('/')) {
87-
return `@${username}`
88-
}
89-
90-
return `[@${username}](${context.host}/${username})`
91-
})
92-
}
93-
}
94-
95-
// remove references that already appear in the subject
96-
commit.references = commit.references.filter(reference => {
97-
if (issues.indexOf(reference.issue) === -1) {
98-
return true
99-
}
100-
101-
return false
102-
})
103-
104-
return commit
105-
}
106-
}
24+
preset: 'angular'
10725
}
10826
}

0 commit comments

Comments
 (0)