Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 56 additions & 46 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
description: "Allowed repository for workflow to run in. Example `ctfpilot/hello-world`."
required: true
type: string
plugins:
description: "Additional plugins to install. Example `@semantic-release/changelog @semantic-release/git`."
required: false
type: string
default: ""
ENVIRONMENT:
description: "The environment to deploy to."
required: false
Expand All @@ -21,6 +26,10 @@ on:
required: false
BUILD_GH_TOKEN:
description: "GitHub Token. Used to authenticate with GitHub at build step. This will overwrite the use of the default GitHub token."
required: false
PYPI_TOKEN:
description: "PyPI Token. Used to authenticate with PyPI at release step if present."
required: false
outputs:
version:
description: "The version of the release. Will be empty if no release was made."
Expand Down Expand Up @@ -71,7 +80,7 @@ jobs:
with:
node-version: "lts/*"
- name: Install dependencies
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
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 ${{ inputs.plugins }} -D
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Detect if configuration file is available for semantic-release
Expand All @@ -85,55 +94,56 @@ jobs:
- name: Set default configuration file for semantic-release
if: steps.check-config.outputs.config_exists == 'false'
run: |
cat << 'EOF' > .releaserc.json
{
"branches": [
"main",
{
"name": "develop",
"prerelease": "r"
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/github",
{
"successComment": false
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "echo ${nextRelease.version} > version.txt",
"publishCmd": "echo 'Published version ${nextRelease.version}'"
}
],
[
"@semantic-release/git",
{
"assets": [],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
}
EOF
cat << 'EOF' > .releaserc.json
{
"branches": [
"main",
{
"name": "develop",
"prerelease": "r"
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "echo ${nextRelease.version} > version.txt",
"publishCmd": "echo 'Published version ${nextRelease.version}'"
}
],
[
"@semantic-release/git",
{
"assets": [],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
[
"@semantic-release/github",
{
"successComment": false
}
]
]
}
EOF
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_GH_TOKEN || secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.RELEASE_GH_TOKEN || secrets.GITHUB_TOKEN }}
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN || '' }}
run: |
npx semantic-release 2>&1 | tee semantic-release.log
status=${PIPESTATUS[0]}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ When the workflow runs on a push to `develop`, it will fail if `main` is ahead o
#### Inputs

- `repository`: Allowed repository for workflow to run in. Example `ctfpilot/hello-world`.
- `plugins`: Additional plugins to install. Example `@semantic-release/changelog @semantic-release/git`
- `ENVIRONMENT`: The environment to deploy to.

#### Secrets

- `RELEASE_GH_TOKEN`: GitHub Token. Used to authenticate with GitHub at release step. This will overwrite the use of the default GitHub token.
- `BUILD_GH_TOKEN`: GitHub Token. Used to authenticate with GitHub at build step. This will overwrite the use of the default GitHub token.
- `PYPI_TOKEN`: PyPI Token. Used to authenticate with PyPI at release step if present.

#### Outputs

Expand Down