diff --git a/.github/actions/release-alpha/action.yml b/.github/actions/release-alpha/action.yml new file mode 100644 index 0000000000..d97c6789c8 --- /dev/null +++ b/.github/actions/release-alpha/action.yml @@ -0,0 +1,25 @@ +name: Release alpha version +description: Runs npm script to release alpha version and pushes tags to github +inputs: + npm-token: + description: Token to push code with + required: true +runs: + using: "composite" + steps: + - name: Configure git user + run: | + git config --local user.email "x@empathy.co" + git config --local user.name "empathy/x" + shell: bash + - name: Create .npmrc file with authorization token + run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc + shell: bash + env: + NPM_TOKEN: ${{ inputs.npm-token }} + - name: Publish release + run: npm run release:alpha + shell: bash + - name: Push changes to GitHub + run: git push --follow-tags + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dde288ffa9..554c0b2aaf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Check branch is releasable +name: Check branch is releasable and release alpha on main branch update on: [push, pull_request] jobs: build: @@ -6,9 +6,18 @@ jobs: container: cypress/browsers:node14.17.0-chrome91-ff89 steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 + token: ${{ secrets.SUPPORT_TOKEN }} - name: Install lerna and all packages run: npm ci - name: Run linter in all packages run: npm run lint - name: Run tests in all packages run: npm run test + - name: Release alpha on non-release pushes to main branch + if: ${{ github.ref_name == 'main' && github.actor != 'support-empathy' && !startsWith(github.event.head_commit.message, 'chore(release):') }} + uses: ./.github/actions/release-alpha + with: + npm-token: ${{ secrets.NPM_TOKEN }} + diff --git a/.github/workflows/release-alpha.yml b/.github/workflows/release-alpha.yml index c90193e588..5e4671d5fb 100644 --- a/.github/workflows/release-alpha.yml +++ b/.github/workflows/release-alpha.yml @@ -1,4 +1,4 @@ -name: Release alpha version +name: Release alpha version on demand on: [workflow_dispatch] jobs: release-alpha: @@ -15,15 +15,7 @@ jobs: run: npm run lint - name: Run tests in all packages run: npm run test - - name: Configure git user - run: | - git config --local user.email "x@empathy.co" - git config --local user.name "empathy/x" - - name: Create .npmrc file with authorization token - run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - - name: Publish release - run: npm run release:alpha - - name: Push changes to GitHub - run: git push --follow-tags + - name: Call release alpha action + uses: ./.github/actions/release-alpha + with: + npm-token: ${{ secrets.NPM_TOKEN }} diff --git a/lerna.json b/lerna.json index 1b974fac80..f88ae91473 100644 --- a/lerna.json +++ b/lerna.json @@ -23,6 +23,9 @@ "command": { "bootstrap": { "npmClientArgs": ["--legacy-peer-deps"] + }, + "version": { + "message": "chore(release): publish" } } } diff --git a/packages/x-components/package.json b/packages/x-components/package.json index cafa3186c5..8f24c25cdb 100644 --- a/packages/x-components/package.json +++ b/packages/x-components/package.json @@ -55,9 +55,7 @@ "test:e2e:ci": "vue-cli-service test:e2e --headless --browser chrome", "test": "npm run test:unit && npm run test:e2e:ci", "cypress:open": "cypress open", - "cypress:open:component": "cypress open-ct", - "release": "standard-version --no-verify", - "release:alpha": "standard-version --no-verify --prerelease alpha" + "cypress:open:component": "cypress open-ct" }, "dependencies": { "@empathyco/x-adapter": "^7.0.0-alpha.9",