Skip to content

Commit

Permalink
Merge branch 'main' into typescript-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
sbsrnt authored Mar 7, 2024
2 parents 7fbdddd + 8dbe1c4 commit f146d57
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 101 deletions.
75 changes: 50 additions & 25 deletions .github/workflows/preview-publish.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: Preview Publish on Label

on:
pull_request:
pull_request_target:
types: [labeled]

jobs:
preview-publish:
if: contains(github.event.pull_request.labels.*.name, 'preview-publish')
name: Publish Prerelease to NPM
create-initial-comment:
name: Create initial pre-release comment
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'preview-publish') }}
steps:
- uses: actions/checkout@v4
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
Expand All @@ -31,7 +32,19 @@ jobs:
}).then(response => {
core.setOutput("comment_id", response.data.id)
});
outputs: ${{ steps.initial_comment.outputs.comment_id }}
outputs:
comment_id: ${{ steps.initial_comment.outputs.comment_id }}

preview-publish:
if: ${{ contains(github.event.pull_request.labels.*.name, 'preview-publish') && (needs.create-initial-comment.result == 'success' }}
name: Publish Prerelease to NPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- uses: actions/setup-node@v4
with:
Expand All @@ -57,32 +70,44 @@ jobs:
run: npm run build

- name: Lerna publish prerelease
id: lerna_publish
id: lerna_prerelease
env:
CI: true
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
output=$(npx lerna version prerelease --preid preview --yes --no-push && npx lerna publish from-git --dist-tag next --yes)
echo "publish_output=$output" >> $GITHUB_OUTPUT # Use the new syntax to set the output
npx lerna version prerelease --preid preview --yes --no-push
npx lerna publish from-git --dist-tag next --yes
echo "publish_output=$(output)" >> $GITHUB_OUTPUT
outputs:
changelog: ${{ steps.lerna_prerelease.outputs.* }}

- name: Update the comment
if: success() && steps.lerna_publish.outcome == 'success'
update-initial-comment:
name: Update initial pre-release comment
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'preview-publish') && (needs.preview-publish.result == 'success' }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- name: Create initial comment
uses: actions/github-script@v7
id: initial_comment
with:
script: |
console.log(steps.initial_comment.outputs)
console.log(steps.lerna_publish.outputs)
const comment_id = ${{ steps.initial_comment.outputs }};
github.rest.issues.updateComment({
...context.repo,
comment_id: comment_id,
body: `🌟 Pre-Release Created 🌟
The pre-release has been successfully created with the following details:
\`\`\`
# ${lernaOutput}
\`\`\`
You can now check out the latest version.
`
});
...context.repo,
comment_id: comment_id,
body: `🌟 Pre-Release Created 🌟
The pre-release has been successfully created with the following details:
\`\`\`
# ${lernaOutput}
\`\`\`
You can now check out the latest version.
`
});
87 changes: 11 additions & 76 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
name: Preview Publish on Label
name: Release

on:
pull_request:
types: [labeled]
push:
branches:
- main

jobs:
create-initial-comment:
name: Create initial pre-release comment
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'preview-publish') }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- name: Create initial comment
uses: actions/github-script@v7
id: initial_comment
with:
script: |
github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: `🚧 Pre-Release Process Initiated 🚧
The pre-release is currently being created. No action is required on your part; this comment will automatically update once everything is complete.
`
}).then(response => {
core.setOutput("comment_id", response.data.id)
});
outputs:
comment_id: ${{ steps.initial_comment.outputs.comment_id }}

preview-publish:
if: ${{ contains(github.event.pull_request.labels.*.name, 'preview-publish') && (needs.create-initial-comment.result == 'success' }}
name: Publish Prerelease to NPM
publish:
name: Publish to NPM
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0 # Fetch-depth 0 necessary to get full commit history for checking changes

- uses: actions/setup-node@v4
with:
Expand All @@ -69,45 +39,10 @@ jobs:
- name: Build
run: npm run build

- name: Lerna publish prerelease
id: lerna_prerelease
- name: Lerna publish
if: success()
env:
CI: true
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npx lerna version prerelease --preid preview --yes --no-push
npx lerna publish from-git --dist-tag next --yes
echo "publish_output=$(output)" >> $GITHUB_OUTPUT
outputs:
changelog: ${{ steps.lerna_prerelease.outputs.* }}

update-initial-comment:
name: Update initial pre-release comment
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'preview-publish') && (needs.preview-publish.result == 'success' }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}

- name: Create initial comment
uses: actions/github-script@v7
id: initial_comment
with:
script: |
github.rest.issues.updateComment({
...context.repo,
comment_id: comment_id,
body: `🌟 Pre-Release Created 🌟
The pre-release has been successfully created with the following details:
\`\`\`
# ${lernaOutput}
\`\`\`
You can now check out the latest version.
`
});
run: lerna publish --yes

0 comments on commit f146d57

Please sign in to comment.