Skip to content

Commit

Permalink
chore(ci): add publish packages workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LironEr committed Aug 17, 2024
1 parent 7deaf2f commit 9bdb8a4
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: publish-packages

on:
push:
tags:
- bundlemon@v*.*.*
- bundlemon-markdown-output@v*.*.*
- bundlemon-utils@v*.*.*

jobs:
test:
name: publish-packages
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # needed for provenance data generation
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract package name
id: package_name
run: echo "value=$(echo $GITHUB_REF_NAME | cut -d '@' -f 1)" >> $GITHUB_OUTPUT

# validate the package.json version is the same as the tag
- name: Validate version
run: |
ACTUAL_VERSION=$(jq -r '.version' packages/${{ steps.package_name.outputs.value }}/package.json)
EXPECTED_VERSION=$(echo $GITHUB_REF_NAME | sed 's/.*@v//')
if [ "$ACTUAL_VERSION" != "$EXPECTED_VERSION" ]; then
echo "Version mismatch between package.json ($ACTUAL_VERSION) and tag ($EXPECTED_VERSION)"
exit 1
fi
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Install dependencies
run: yarn

- name: Build
run: yarn nx build ${{ steps.package_name.outputs.value }}

- name: Publish packages
run: yarn nx release publish --projects ${{ steps.package_name.outputs.value }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
NPM_CONFIG_PROVENANCE: true
21 changes: 21 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@
}
}
],
"release": {
"projects": ["packages/*"],
"projectsRelationship": "independent",
"releaseTagPattern": "{projectName}@v{version}",
"changelog": {
"projectChangelogs": {
"file": "packages/{projectName}/CHANGELOG.md",
"createRelease": "github"
},
"git": {
"commitMessage": "chore(release): {projectName} bump version [skip ci]"
}
},
"conventionalCommits": {
"types": {
"chore": {
"changelog": true
}
}
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": ["{workspaceRoot}/tsconfig.base.json", "{workspaceRoot}/nx.json"],
Expand Down

0 comments on commit 9bdb8a4

Please sign in to comment.