Skip to content

Commit

Permalink
ci: only do release commit on main
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacThoman committed Dec 4, 2024
1 parent 1d48cb8 commit c37d0be
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 59 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ jobs:
- name: Run security audit
run: npm audit --audit-level=high

# Release Job (Only for main and dev branches)
# Release Job (Only for main and dev branches)
release:
if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/dev')
name: Release
name: release
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -140,18 +140,10 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Create public directory
run: mkdir -p public
- name: Create initial version file if not exists
run: |
if [ ! -f public/gameVersion.json ]; then
echo '{"version": "0.0.0"}' > public/gameVersion.json
fi
- name: Install dependencies
run: npm clean-install
- name: Verify the integrity of dependencies
run: npm audit signatures
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
run: npx semantic-release --branch ${GITHUB_REF#refs/heads/} --ci
run: |
npx semantic-release --extends ./release.config.js
50 changes: 3 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,9 @@
"three": "^0.169.0",
"three-mesh-bvh": "^0.8.2"
},
"release": {
"branches": [
"main",
{
"name": "dev",
"prerelease": "beta"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"semantic-release-replace-plugin",
{
"replacements": [
{
"files": [
"public/gameVersion.json"
],
"from": "\"version\": \".*\"",
"to": "\"version\": \"${nextRelease.version}\"",
"results": [
{
"file": "public/gameVersion.json",
"hasChanged": true,
"numMatches": 1,
"numReplacements": 1
}
],
"countMatches": true
}
]
}
],
[
"@semantic-release/git",
{
"assets": [
"public/gameVersion.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
],
"@semantic-release/github"
]
},
"devDependencies": {


"devDependencies": {
"semantic-release-replace-plugin": "^1.2.7"
}
}
39 changes: 39 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
branches: [
'main',
{ name: 'dev', prerelease: 'beta' },
],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
'@semantic-release/github',
{
successComment: false,
},
],
// Conditionally include these plugins only when on 'main' branch
...(process.env.GITHUB_REF_NAME === 'main' ? [
[
'semantic-release-replace-plugin',
{
replacements: [
{
files: ['public/gameVersion.json'],
from: '"version": ".*"',
to: '"version": "${nextRelease.version}"',
countMatches: true,
},
],
},
],
[
'@semantic-release/git',
{
assets: ['public/gameVersion.json'],
message: 'chore: release ${nextRelease.version} [skip ci]',
},
],
] : []),
],
};

0 comments on commit c37d0be

Please sign in to comment.