From b33734a0d49263c10b6c9ac8238572db6cdcde3a Mon Sep 17 00:00:00 2001 From: Miguel Garcia Garcia Date: Mon, 4 Mar 2024 14:25:18 +0100 Subject: [PATCH] ci: add semantic-release to publish workflow --- .github/workflows/publish.yml | 24 ++++++++++++++++++++---- package.json | 2 +- release.config.js | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 release.config.js diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0c017c0..4ed0ef7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,6 +3,9 @@ name: Publish on: release: types: [published] + workflow_dispatch: + push: + branches: [add-semantic-release] jobs: build: @@ -10,9 +13,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 + persist-credentials: false + - uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 20.x + + - name: Install semantic-release extra plugins + run: npm install --save-dev @semantic-release/changelog @semantic-release/git - name: Install run: yarn @@ -20,7 +30,13 @@ jobs: - name: Build run: yarn build + # - name: Publish + # uses: JS-DevTools/npm-publish@v3 + # with: + # token: ${{ secrets.CERN_SIS_NPM }} + - name: Publish - uses: JS-DevTools/npm-publish@v3 - with: - token: ${{ secrets.CERN_SIS_NPM }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.CERN_SIS_NPM }} + run: npx semantic-release diff --git a/package.json b/package.json index fa6c854..ee1f8df 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "git+https://github.com/cern-sis/react-formule.git" + "url": "git@github.com:miguelgrc/react-formule.git" }, "type": "module", "files": [ diff --git a/release.config.js b/release.config.js new file mode 100644 index 0000000..ec63563 --- /dev/null +++ b/release.config.js @@ -0,0 +1,17 @@ +export default { + branches: ["add-semantic-release"], + plugins: [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/npm", + + [ + "@semantic-release/git", + { + assets: ["package.json", "CHANGELOG.md"], + message: + "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}", + }, + ], + ], +};