-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/import-in-script-blocks
- Loading branch information
Showing
1 changed file
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ env: | |
jobs: | ||
preview-mode: | ||
name: Enter preview mode | ||
if: ${{ github.repository_owner == 'Fryuni' && github.event.issue.pull_request && (contains(github.event.comment.body, '!preview') || contains(github.event.comment.body, '/preview') }} | ||
if: ${{ github.repository_owner == 'Fryuni' && github.event.issue.pull_request && (contains(github.event.comment.body, '!snapshot') || contains(github.event.comment.body, '/snapshot') }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
|
@@ -37,7 +37,7 @@ jobs: | |
with: | ||
script: | | ||
const { body } = context.payload.comment; | ||
const PREVIEW_RE = /^[!\/](?:preview|snapshot)\s+(\S*)\s*$/gim; | ||
const PREVIEW_RE = /^[!\/]snapshot\s+(\S*)\s*$/gim; | ||
const [_, name] = PREVIEW_RE.exec(body) ?? []; | ||
if (name) return name; | ||
|
@@ -77,16 +77,84 @@ jobs: | |
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Enter pre-release mode | ||
- name: Build Packages | ||
run: pnpm run build | ||
|
||
- name: Bump Package Versions | ||
id: changesets | ||
run: | | ||
pnpm exec changeset status --output status.output.json 2>&1 | ||
pnpm exec changeset version --snapshot ${{ steps.getSnapshotName.outputs.result }} | ||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | ||
echo "status<<$EOF" >> $GITHUB_OUTPUT | ||
echo "$(cat status.output.json)" >> $GITHUB_OUTPUT | ||
echo "$EOF" >> $GITHUB_OUTPUT | ||
env: | ||
# Needs access to run the script | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Disable color | ||
FORCE_COLOR: 0 | ||
NO_COLOR: 1 | ||
|
||
- name: Publish Release | ||
id: publish | ||
run: | | ||
pnpm changeset pre enter ${{ steps.getPreviewName.outputs.result }} | ||
pnpm version | ||
GITHUB_ACTIONS=0 pnpm run build > build.output.txt 2>&1 | ||
pnpm exec changeset publish --tag pr--${{ steps.getSnapshotName.outputs.result }} > publish.output.txt 2>&1 | ||
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | ||
echo "build<<$EOF" >> $GITHUB_OUTPUT | ||
echo "$(cat build.output.txt)" >> $GITHUB_OUTPUT | ||
echo "$EOF" >> $GITHUB_OUTPUT | ||
cat build.output.txt | ||
echo "publish<<$EOF" >> $GITHUB_OUTPUT | ||
echo "$(cat publish.output.txt)" >> $GITHUB_OUTPUT | ||
echo "$EOF" >> $GITHUB_OUTPUT | ||
cat publish.output.txt | ||
env: | ||
# Needs access to publish to npm | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
# Disable color | ||
FORCE_COLOR: 0 | ||
NO_COLOR: 1 | ||
|
||
- name: Commit | ||
uses: EndBug/add-and-commit@v9 | ||
- name: Pull Request Notification | ||
uses: actions/github-script@v7 | ||
env: | ||
TAG: ${{ steps.getSnapshotName.outputs.result }} | ||
STATUS_DATA: ${{ steps.changesets.outputs.status }} | ||
BUILD_LOG: ${{ steps.publish.outputs.build }} | ||
PUBLISH_LOG: ${{ steps.publish.outputs.publish }} | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.COMMIT_TOKEN }} | ||
message: Enter pre-release mode | ||
author_name: Croct Bot | ||
author_email: [email protected] | ||
script: | | ||
let changeset = { releases: [] }; | ||
try { | ||
changeset = JSON.parse(process.env.STATUS_DATA); | ||
} catch (e) {} | ||
let message = 'Snapshots have been released for the following packages:' | ||
for (const release of changeset.releases) { | ||
if (release.type === 'none') continue; | ||
message += `\n- \`${release.name}@experimental--${process.env.TAG}\``; | ||
} | ||
function details(title, body) { | ||
message += '\n'; | ||
message += `<details><summary><strong>${title}</strong></summary>` | ||
message += '\n\n```\n'; | ||
message += body; | ||
message += '\n```\n\n</details>'; | ||
} | ||
details('Publish Log', process.env.PUBLISH_LOG); | ||
details('Build Log', process.env.BUILD_LOG); | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: message, | ||
}) |