This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Orb Agent - PR Semantic Release Check | |
on: | |
pull_request: | |
branches: [ release ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref }} | |
cancel-in-progress: true | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SEMANTIC_RELEASE_PACKAGE: ${{ github.repository }} | |
APP_NAME: orb-agent | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
semantic-release-dry-run: | |
name: Semantic Release Dry Run | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
- name: Write package.json | |
uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 #v1.3 | |
with: | |
path: ./package.json | |
write-mode: overwrite | |
contents: | | |
{ | |
"name": "${{ env.APP_NAME }}", | |
"version": "1.0.0", | |
"devDependencies": { | |
"semantic-release-export-data": "^1.0.1", | |
"semantic-release": "25.0.0-beta.6", | |
"@semantic-release/changelog": "^6.0.3" | |
} | |
} | |
- name: Write .releaserc.json | |
uses: DamianReeves/write-file-action@6929a9a6d1807689191dcc8bbe62b54d70a32b42 #v1.3 | |
with: | |
path: ./.releaserc.json | |
write-mode: overwrite | |
contents: | | |
{ | |
"branches": "release", | |
"repositoryUrl": "https://github.com/netboxlabs/orb-agent", | |
"debug": "true", | |
"tagFormat": "v${version}", | |
"plugins": [ | |
["semantic-release-export-data"], | |
["@semantic-release/commit-analyzer", { | |
"releaseRules": [ | |
{ "message": "*", "release": "patch"}, | |
{ "message": "fix*", "release": "patch" }, | |
{ "message": "feat*", "release": "minor" }, | |
{ "message": "major*", "release": "major" } | |
] | |
}], | |
"@semantic-release/release-notes-generator", | |
[ | |
"@semantic-release/changelog", | |
{ | |
"changelogFile": "CHANGELOG.md", | |
"changelogTitle": "# Semantic Versioning Changelog" | |
} | |
], | |
[ | |
"@semantic-release/github", | |
{ | |
"assets": [ | |
{ | |
"path": "release/**" | |
} | |
] | |
} | |
] | |
] | |
} | |
- name: Install dependencies | |
run: npm install --legacy-peer-deps | |
- name: Run semantic-release dry-run | |
id: semantic-release | |
run: npx semantic-release --debug --dry-run | |
- name: Comment PR with results | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { data: commits } = await github.rest.pulls.listCommits({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number | |
}); | |
const commitMessages = commits.map(commit => commit.commit.message).join('\n'); | |
let comment = `## Semantic Release Dry Run Results 🔍\n\n`; | |
if (process.env.NEW_RELEASE_PUBLISHED === 'true') { | |
comment += `✅ **A new release would be published!**\n\n`; | |
comment += `**Version:** ${process.env.NEW_RELEASE_VERSION}\n\n`; | |
comment += `**Commit Messages:**\n\`\`\`\n${commitMessages}\n\`\`\`\n\n`; | |
comment += `This PR would trigger a ${process.env.NEW_RELEASE_TYPE || 'patch'} release.`; | |
} else { | |
comment += `ℹ️ **No new release would be published**\n\n`; | |
comment += `**Commit Messages:**\n\`\`\`\n${commitMessages}\n\`\`\`\n\n`; | |
comment += `No semantic changes detected that would trigger a release.`; | |
} | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: comment | |
}); | |
env: | |
NEW_RELEASE_PUBLISHED: ${{ steps.semantic-release.outputs.new-release-published }} | |
NEW_RELEASE_VERSION: ${{ steps.semantic-release.outputs.new-release-version }} | |
NEW_RELEASE_TYPE: ${{ steps.semantic-release.outputs.new-release-type }} |