Skip to content

Commit

Permalink
ci: make releases create a new PR instead of committing in main. (#11)
Browse files Browse the repository at this point in the history
ci: make releases create a new PR instead of committing in main.

EX-3886
  • Loading branch information
javieri-empathy authored May 17, 2021
1 parent e09d20a commit 5a157e9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "empathy/x"
- name: Prepare the release
run: "npm run prepare-release:${{ github.event.inputs.kind }}"
- name: Push changes
uses: ad-m/github-push-action@master
run: npm run prepare-release:${{ github.event.inputs.kind }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
github_token: ${{ secrets.SUPPORT_TOKEN }}
branch: ${{ github.ref }}
token: ${{ secrets.SUPPORT_TOKEN }}
commit-message: "chore(release): prepare ${{ github.event.inputs.kind }} release"
committer: Interface X <[email protected]>
title: ${{ github.event.inputs.kind }} release
body: Release preparation
branch: release
delete-branch: true
9 changes: 6 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Release a new version
on:
workflow_dispatch:
pull_request:
types: [ closed ]
branches: [ main ]
jobs:
release:
if: github.event.pull_request.merged == true && github.head_ref == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -29,8 +32,8 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish the release
run: 'npm run publish-release'
- name: Push changes
run: npm run publish-release
- name: Push tags
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.SUPPORT_TOKEN }}
Expand Down
13 changes: 7 additions & 6 deletions scripts/prepare-release.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const { exec } = require('./utils');

const [releaseKind = 'stable'] = process.argv.slice(2);
const releaseKindArgument = releaseKind === 'alpha' ? '--conventional-prerelease' : '--conventional-graduate';
execLernaVersion();

[
`lerna version --conventional-commits --no-git-tag-version --yes ${ releaseKindArgument }`,
`git commit -m "chore(release): prepare ${releaseKind} release" -a`
].forEach(exec);
function execLernaVersion() {
const [releaseKind = 'stable'] = process.argv.slice(2);
const releaseKindArgument =
releaseKind === 'alpha' ? '--conventional-prerelease' : '--conventional-graduate';
exec(`lerna version --conventional-commits --no-git-tag-version --yes ${releaseKindArgument}`);
}
16 changes: 10 additions & 6 deletions scripts/publish-release.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const { exec } = require('./utils');

const changedPackages = JSON.parse(exec('lerna changed --json'));
exec(`lerna publish from-package --yes`);
changedPackages.forEach(changed => {
const tag = `${ changed.name }@${ changed.version }`;
exec(`git tag -a ${tag} -m "${tag}"`);
});
addVersionTagForChangedPackages();

function addVersionTagForChangedPackages() {
const changedPackages = JSON.parse(exec('lerna changed --json'));
exec(`lerna publish from-package --yes`);
changedPackages.forEach(changed => {
const tag = `${changed.name}@${changed.version}`;
exec(`git tag -a ${tag} -m "${tag}"`);
});
}

0 comments on commit 5a157e9

Please sign in to comment.