semantic-release / git

:twisted_rightwards_arrows: semantic-release plugin to commit release assets to the project's git repository
MIT License
304 stars 67 forks source link

Can not push tags to GitHub #170

Closed hashim-sohail closed 5 years ago

hashim-sohail commented 5 years ago

I'm running into this error when running semantic-release in GitHub Actions

Step

      - name: Semantic Release
        env:
          GITHUB_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
        run: npx semantic-release@beta

Releaserc

module.exports = {
    // https://github.com/semantic-release/evolution/blob/release-workflows/_drafts/release-workflows.md#pre-releases
    branches: [
        'master',
        'next',
        { name: 'beta', prerelease: true },
        { name: 'alpha', prerelease: true },
    ],
    plugins: [
        '@semantic-release/commit-analyzer',
        '@semantic-release/release-notes-generator',
        '@semantic-release/changelog',
        [
            '@semantic-release/exec',
            {
                prepareCmd: 'yarn fix:md',
            },
        ],
        [
            '@semantic-release/exec',
            {
                prepareCmd: 'yarn fix:prettier',
            },
        ],
        '@semantic-release/npm',
        './scripts/version.js',
        [
            '@semantic-release/git',
            {
                assets: ['src/version.ts', 'CHANGELOG.md', 'package.json'],
                message:
                    'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
            },
        ],
        '@semantic-release/github',
        // "@qiwi/semantic-release-gh-pages-plugin"
    ],
};

Package Versions

                "@semantic-release/changelog": "^3.0.4",
        "@semantic-release/commit-analyzer": "^6.3.0",
        "@semantic-release/exec": "^3.3.3",
        "@semantic-release/git": "^7.1.0-beta.3",
        "@semantic-release/github": "^5.4.3",
        "@semantic-release/npm": "^5.1.15",
        "@semantic-release/release-notes-generator": "^7.3.0",

Error

To https://github.com/BlueBaseJS/core.git
 ! [remote rejected]   HEAD -> master (protected branch hook declined)
error: failed to push some refs to 'https://x-access-token:[secure]@github.com/BlueBaseJS/core.git'

    at makeError (/__w/core/core/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/__w/core/core/node_modules/execa/index.js:278:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  code: 1,
  stdout: '',
  stderr:
   'remote: error: GH006: Protected branch update failed for refs/heads/master.        \nremote: error: You\'re not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.        \nTo https://github.com/BlueBaseJS/core.git\n ! [remote rejected]   HEAD -> master (protected branch hook declined)\nerror: failed to push some refs to \'https://x-access-token:[secure]@github.com/BlueBaseJS/core.git\'\n',
  failed: true,
  signal: null,
  cmd:
   'git push --tags https://x-access-token:[secure]@github.com/BlueBaseJS/core.git HEAD:master',
  timedOut: false,
  killed: false,
  pluginName: '@semantic-release/git' }

What permissions and setting I need to enable for GitHub personal access token so it can work with release? Currently removing protection to make release pass

pvdlg commented 5 years ago

Please see https://github.com/semantic-release/semantic-release/blob/master/docs/recipes/github-actions.md#pushing-packagejson-changes-to-a-master-branch

hashim-sohail commented 5 years ago

What would be the steps in this job?

name: Release
on:
  repository_dispatch:
    types: [semantic-release]
jobs:
# ...
pvdlg commented 5 years ago

You have an example config there: https://github.com/semantic-release/semantic-release/blob/master/docs/recipes/github-actions.md#githubworkflowsreleaseyml-configuration-for-node-projects