Skip to content

Commit a660bdd

Browse files
authored
Merge pull request #129 from rees46/feat/composite
feat: composites
2 parents c34b6ba + 96b8d75 commit a660bdd

5 files changed

+201
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Composite start JS action
2+
description: Prepare JS action - checkout, generate App token, yarn install
3+
4+
inputs:
5+
nodeVersion:
6+
description: Node version to run this workflow. Default 18 as it is in action cache
7+
default: '18'
8+
required: false
9+
appId:
10+
description: App ID for committing and pushing
11+
required: true
12+
appSecret:
13+
description: App secret for committing changes
14+
required: true
15+
16+
runs:
17+
using: composite
18+
19+
steps:
20+
- uses: actions/create-github-app-token@v1
21+
id: app-token
22+
with:
23+
app-id: ${{ inputs.appId }}
24+
private-key: ${{ inputs.appSecret }}
25+
shell: bash
26+
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
token: ${{ steps.app-token.outputs.token }}
32+
ref: master
33+
shell: bash
34+
35+
- name: Setup Node
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: ${{ inputs.nodeVersion }}
39+
shell: bash
40+
41+
- name: Install
42+
run: yarn install --inline-builds
43+
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Version composite action
2+
description: patch versions of changed packages
3+
4+
inputs:
5+
private:
6+
description: Should apply only to private?
7+
required: false
8+
default: 'false'
9+
checkChanges:
10+
description: Should run 'yarn --since'?
11+
required: false
12+
default: 'true'
13+
token:
14+
description: GitHub PAT
15+
required: true
16+
17+
outputs:
18+
baseCommit:
19+
description: Find last merge commits
20+
value: ${{ steps.find_base_commit.outputs.baseCommit }}
21+
22+
runs:
23+
using: composite
24+
25+
steps:
26+
- name: Find Base Commit for master
27+
id: find_base_commit
28+
run: |
29+
BASE_COMMIT=$(git log --merges -n 2 --format=format:%H | tail -n 1)
30+
echo "baseCommit=$BASE_COMMIT" >> $GITHUB_OUTPUT
31+
echo "Base Commit: $BASE_COMMIT"
32+
shell: bash
33+
34+
- name: List changed workspaces
35+
env:
36+
BASE_COMMIT: ${{ steps.find_base_commit.outputs.baseCommit }}
37+
run: yarn workspaces list --since=$BASE_COMMIT^
38+
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish composite action
2+
description: create changelog and publish if applicable
3+
4+
inputs:
5+
onlyChangelog:
6+
required: false
7+
default: 'false'
8+
description: Should only create changelog without publish
9+
npmAuthToken:
10+
required: false
11+
description: NPM token for publishing
12+
token:
13+
required: true
14+
description: GitHub PAT
15+
baseCommit:
16+
required: true
17+
description: Base commit from which to parse workspace changes
18+
19+
20+
runs:
21+
using: composite
22+
23+
steps:
24+
- name: Generate changelog
25+
env:
26+
GITHUB_TOKEN: ${{ inputs.token }}
27+
BASE_COMMIT: ${{ inputs.baseCommit }}
28+
run: yarn workspaces foreach --since=$BASE_COMMIT^ --verbose run changelog
29+
shell: bash
30+
31+
- name: Publish
32+
if: inputs.onlyChangelog == 'false'
33+
env:
34+
YARN_NPM_AUTH_TOKEN: ${{ inputs.npmAuthToken }}
35+
BASE_COMMIT: ${{ inputs.baseCommit }}
36+
run: yarn workspaces foreach --since=$BASE_COMMIT^ --verbose --topological --no-private npm publish --access public
37+
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Composite release JS action
2+
description: Release action - create and publish release with source code
3+
4+
inputs:
5+
isMonorepo:
6+
required: false
7+
default: 'false'
8+
description: Treat this repo as monorepo. If true - tags for releases will include package names
9+
baseCommit:
10+
required: true
11+
description: Base commit from which to parse changed workspaces
12+
token:
13+
required: true
14+
description: GitHub PAT
15+
16+
runs:
17+
using: composite
18+
19+
steps:
20+
- name: Release monorepo
21+
if: inputs.isMonorepo == 'true'
22+
env:
23+
BASE_COMMIT: ${{ inputs.baseCommit }}
24+
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
25+
run: yarn workspaces foreach --since=$BASE_COMMIT^ exec 'bash -c "yarn pack && VERSION=$npm_package_version && NAME=$npm_package_name && gh release create \"\$NAME-v\$VERSION\" ./package.tgz --title=\$NAME-\$VERSION --notes-file=./CHANGELOG.md"'
26+
shell: bash
27+
28+
- name: Release single package
29+
if: inputs.isMonorepo == 'false'
30+
env:
31+
BASE_COMMIT: ${{ inputs.baseCommit }}
32+
GH_TOKEN: ${{ inputs.GITHUB_TOKEN }}
33+
run: yarn workspaces foreach --since=$BASE_COMMIT^ exec 'bash -c "yarn pack && VERSION=$npm_package_version && gh release create \"v\$VERSION\" ./package.tgz --title=\$VERSION --notes-file=./CHANGELOG.md"'
34+
shell: bash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Version composite action
2+
description: patch versions of changed packages
3+
4+
inputs:
5+
private:
6+
description: Should apply only to private?
7+
required: false
8+
default: 'false'
9+
checkChanges:
10+
description: Should run 'yarn --since'?
11+
required: false
12+
default: 'true'
13+
token:
14+
description: GitHub PAT
15+
required: true
16+
17+
outputs:
18+
committed:
19+
description: Have the changes in version been committed?
20+
value: ${{ jobs.run.outputs.committed }}
21+
22+
runs:
23+
using: composite
24+
25+
steps:
26+
- name: List changed workspaces
27+
env:
28+
BASE_COMMIT: ${{ steps.find_base_commit.outputs.baseCommit }}
29+
run: yarn workspaces list --since=$BASE_COMMIT^
30+
shell: bash
31+
32+
- name: Version
33+
env:
34+
GITHUB_TOKEN: ${{ inputs.token }}
35+
IS_PRIVATE: ${{ inputs.private }}
36+
SHOULD_CHECK_CHANGES: ${{ inputs.checkChanges }}
37+
run: |
38+
if [ $IS_PRIVATE == 'false' ]; then
39+
PRIVATE_FLAG="--no-private"
40+
fi
41+
42+
if [ $SHOULD_CHECK_CHANGES == 'true' ]; then
43+
CHANGES_FLAG="--since=${{ steps.find_base_commit.outputs.baseCommit }}^"
44+
else
45+
CHANGES_FLAG="--all"
46+
fi
47+
48+
yarn workspaces foreach $CHANGES_FLAG $PRIVATE_FLAG --verbose version patch --immediate
49+
shell: bash

0 commit comments

Comments
 (0)