Skip to content

Commit

Permalink
ci: pre release workflow not working
Browse files Browse the repository at this point in the history
  • Loading branch information
rizqitsani committed Jan 7, 2024
1 parent cec006a commit 11ad00f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
with:
node-version: 18
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'

- name: Install Dependencies
run: pnpm install --frozen-lockfile
Expand All @@ -34,23 +35,22 @@ jobs:
run: pnpm run build --filter=docs^...

- name: Create Pre-Release Version
id: changesets
run: |
pnpm changeset version --snapshot "alpha-${{ github.event.pull_request.number }}"
pnpm publish --tag "alpha-${{ github.event.pull_request.number }}" --no-git-checks --no-git-tag --snapshot
pnpm changeset version --snapshot alpha
pnpm run publish --tag alpha --no-git-checks
echo "::set-output name=published::true"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Get published package version
if: steps.changesets.outputs.published == 'true'
id: version
run: |
name=$(echo $changeset_outputs_published_packages | jq '.[0].name')
version=$(echo $changeset_outputs_published_packages | jq '.[0].version')
echo "::set-output name=version::$version"
echo "::set-output name=name::$name"
env:
changeset_outputs_published_packages: ${{ steps.changesets.outputs.publishedPackages }}
published_packages="$(node scripts/published-package.js)"
formatted_packages=$(echo $published_packages | jq -r '.[] | "\(.name)@\(.version)"')
echo "::set-output name=packages::$formatted_packages"
- name: Find Comment
if: steps.changesets.outputs.published == 'true'
Expand All @@ -70,7 +70,7 @@ jobs:
body: |
:tada: New Pre-Release Version :tada:
${{ steps.version.outputs.name }}@${{ steps.version.outputs.version }}
${{ steps.version.outputs.packages }}
:warning: Please use with caution. All the pre-release packages are only for testing purposes and are not intended to be used in production.
edit-mode: replace
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"changeset": "changeset",
"version-packages": "changeset version",
"release": "turbo run build --filter=docs^... && changeset publish",
"publish": "changeset publish",
"prepare": "husky install"
},
"devDependencies": {
Expand Down
25 changes: 25 additions & 0 deletions scripts/published-package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { execSync } = require('child_process');
const fs = require('fs');

(() => {
try {
const gitStatus = execSync('git status | grep package.json').toString();
if (gitStatus) {
const publishedPackages = gitStatus
.replace(/(?:\n)/g, ',')
.replace(/(?:\n|\s|modified:)/g, '')
.split(',')
.filter((v) => !!v)
.map((path) => {
const { name, version } = JSON.parse(fs.readFileSync(path, 'utf8'));

return {
name,
version,
};
});

console.log(JSON.stringify(publishedPackages));
}
} catch (e) {}
})();

0 comments on commit 11ad00f

Please sign in to comment.