Skip to content

Commit 8c335b0

Browse files
authored
Move to local version of release system (#5)
2 parents fcc2d52 + 0370074 commit 8c335b0

1 file changed

Lines changed: 94 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 94 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,103 @@ on:
2323
description: "GitHub Token. Used to authenticate with GitHub at build step. This will overwrite the use of the default GitHub token."
2424
outputs:
2525
version:
26-
description: "The version of the release. Will be null if no release was made."
27-
value: ${{ jobs.release.outputs.version }}
26+
description: "The version of the release. Will be empty if no release was made."
27+
value: ${{ jobs.semantic-release.outputs.version }}
2828

2929
jobs:
30-
release:
30+
semantic-release:
31+
name: Semantic release
32+
runs-on: ubuntu-latest
33+
environment: ${{ inputs.ENVIRONMENT || '' }}
3134
permissions:
3235
contents: write
3336
packages: write
3437
id-token: write
35-
name: Release
36-
if: github.repository == ( inputs.repository || 'ctfpilot/ci')
37-
uses: the0mikkel/ci/.github/workflows/semver-release-standalone.yml@v1.4.1
38-
secrets: inherit
39-
with:
40-
ENVIRONMENT: ${{ inputs.ENVIRONMENT }}
38+
outputs:
39+
version: ${{ steps.version.outputs.version }}
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0
45+
persist-credentials: false
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v6
48+
with:
49+
node-version: "lts/*"
50+
- name: Install dependencies
51+
run: npm install semantic-release @semantic-release/exec @semantic-release/commit-analyzer @semantic-release/git @semantic-release/github @semantic-release/release-notes-generator conventional-changelog-conventionalcommits -D
52+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
53+
run: npm audit signatures
54+
- name: Detect if configuration file is available for semantic-release
55+
id: check-config
56+
run: |
57+
if [ -f .releaserc.json ] || [ -f .releaserc ] || [ -f release.config.js ]; then
58+
echo "config_exists=true" >> $GITHUB_OUTPUT
59+
else
60+
echo "config_exists=false" >> $GITHUB_OUTPUT
61+
fi
62+
- name: Set default configuration file for semantic-release
63+
if: steps.check-config.outputs.config_exists == 'false'
64+
run: |
65+
cat << 'EOF' > .releaserc.json
66+
{
67+
"branches": [
68+
"main",
69+
{
70+
"name": "develop",
71+
"prerelease": "r"
72+
}
73+
],
74+
"plugins": [
75+
[
76+
"@semantic-release/commit-analyzer",
77+
{
78+
"preset": "conventionalcommits"
79+
}
80+
],
81+
[
82+
"@semantic-release/release-notes-generator",
83+
{
84+
"preset": "conventionalcommits"
85+
}
86+
],
87+
[
88+
"@semantic-release/github",
89+
{
90+
"successComment": false
91+
}
92+
],
93+
[
94+
"@semantic-release/exec",
95+
{
96+
"prepareCmd": "echo ${nextRelease.version} > version.txt",
97+
"publishCmd": "echo 'Published version ${nextRelease.version}'"
98+
}
99+
],
100+
[
101+
"@semantic-release/git",
102+
{
103+
"assets": [],
104+
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
105+
}
106+
]
107+
]
108+
}
109+
EOF
110+
- name: Release
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.RELEASE_GH_TOKEN || secrets.GITHUB_TOKEN }}
113+
NPM_TOKEN: ${{ secrets.RELEASE_GH_TOKEN || secrets.GITHUB_TOKEN }}
114+
run: |
115+
npx semantic-release 2>&1 | tee semantic-release.log
116+
status=${PIPESTATUS[0]}
117+
exit $status
118+
- name: Archive release log
119+
uses: actions/upload-artifact@v5
120+
with:
121+
name: semantic-release.log
122+
path: semantic-release.log
123+
- name: Get version
124+
id: version
125+
run: echo version=$(grep -oP "next release version is \K.*" semantic-release.log || echo "") >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)