diff --git a/.github/actions/bump-version/action.yml b/.github/actions/bump-version/action.yml deleted file mode 100644 index 8936004c..00000000 --- a/.github/actions/bump-version/action.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: 'Bump version' -description: 'Bump version in files' -runs: - using: 'node20' - main: 'index.js' diff --git a/.github/actions/bump-version/index.js b/.github/actions/bump-version/index.js deleted file mode 100644 index 044a2b08..00000000 --- a/.github/actions/bump-version/index.js +++ /dev/null @@ -1,39 +0,0 @@ -const path = require('path'); -const core = require('@actions/core'); -const github = require('@actions/github'); -const exec = require('@actions/exec'); - -const run = async () => { - core.info('Setup octokit'); - const octokit = github.getOctokit(process.env.GITHUB_TOKEN); - const { owner, repo } = github.context.repo; - - core.info('Fetch latest release info'); - const latestRelease = await octokit.rest.repos.getLatestRelease({ - owner, - repo, - }); - - core.info('Set variables'); - const version = latestRelease.data.tag_name.slice(1); - - core.info('Update files version field'); - await exec.exec('node', [path.join(process.env.GITHUB_WORKSPACE, './scripts/update-version.js'), version]); - - await exec.exec('git', ['config', '--global', 'user.name', 'github-actions[bot]']); - await exec.exec('git', ['config', '--global', 'user.email', '41898282+github-actions[bot]@users.noreply.github.com']); - - const branch = `bump-version-${version}`; - - // Delete the remote branch if it already exists (e.g. from a previous run) - await exec.exec('git', ['push', 'origin', '--delete', branch]).catch(() => {}); - - await exec.exec('git', ['checkout', '-B', branch]); - await exec.exec('git', ['commit', '-am', `chore: release ${version}`]); - await exec.exec('git', ['push', '-u', 'origin', branch]); - await exec.exec('gh', ['pr', 'create', '--fill']); -}; - -run() - .then(() => core.info('Updated files version successfully')) - .catch(error => core.setFailed(error.message)); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a156886..2cfb3006 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,12 +22,11 @@ jobs: run: npm ci - name: Run tests run: grunt test - # Release using semantic-relaease if there are new smenatic commits + # Release using semantic-release if there are new semantic commits. + # The @semantic-release/git plugin commits the version bump + # (package.json, package-lock.json, app/manifest.json, CHANGELOG.md) + # directly back to master. - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: npx semantic-release - - name: Bump Version - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: ./.github/actions/bump-version diff --git a/.releaserc.json b/.releaserc.json index f14f306e..0644492a 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -9,6 +9,18 @@ "prepareCmd": "node ./scripts/update-version.js ${nextRelease.version} && npm i" } ], + [ + "@semantic-release/git", + { + "assets": [ + "package.json", + "package-lock.json", + "app/manifest.json", + "CHANGELOG.md" + ], + "message": "chore(release): ${nextRelease.version}" + } + ], [ "@semantic-release/github", {