|
19 | 19 | # "commits" contains an array of objects where one of the properties is the commit "message" |
20 | 20 | # Release workflow will be skipped if release conventional commits are not used |
21 | 21 | if: | |
22 | | - startsWith( github.repository, 'asyncapi/' ) && |
23 | 22 | (startsWith( github.event.commits[0].message , 'fix:' ) || |
24 | 23 | startsWith( github.event.commits[0].message, 'fix!:' ) || |
25 | 24 | startsWith( github.event.commits[0].message, 'feat:' ) || |
@@ -117,21 +116,37 @@ jobs: |
117 | 116 | - if: steps.packagejson.outputs.exists == 'true' |
118 | 117 | name: Publish to any of NPM, Github, and Docker Hub |
119 | 118 | #this step has 2 goals, it is either identifying that there is changeset file created and then this action creates a PR with version bump that will trigger release - or if it sees there is no changeset, and there are versions changes in package.json files, it publish new versions to NPM is they are not there yet |
| 119 | + # However, as currently changeset's publish isn't working well with OIDC next step will directly publish to NPM if there are version changes but no changesets |
120 | 120 | uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 |
121 | 121 | id: release |
122 | 122 | with: |
123 | 123 | version: npm run bump:version |
124 | 124 | commit: "chore(release): release and bump versions of packages" |
125 | 125 | title: "chore(release): release and bump versions of packages" |
126 | | - publish: npx -p @changesets/cli@2.27.7 changeset publish |
| 126 | + # Working around changesets action not supporting OIDC yet. Need to pass successful release output for triggering github release |
| 127 | + publish: npm run publish:trusted |
127 | 128 | setupGitUser: false |
128 | 129 | env: |
129 | | - NPM_TOKEN: '' |
130 | 130 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
131 | 131 | GIT_AUTHOR_NAME: asyncapi-bot |
132 | 132 | GIT_AUTHOR_EMAIL: info@asyncapi.io |
133 | 133 | GIT_COMMITTER_NAME: asyncapi-bot |
134 | 134 | GIT_COMMITTER_EMAIL: info@asyncapi.io |
| 135 | + |
| 136 | + - name: Publish to NPM directly (skip if version already published) |
| 137 | + if: steps.packagejson.outputs.exists == 'true' && steps.release.outputs.hasChangesets == 'false' |
| 138 | + shell: bash |
| 139 | + run: | |
| 140 | + # Check if the version in package.json is already published |
| 141 | + VERSION=$(node -p "require('./package.json').version") |
| 142 | + PACKAGE_NAME=$(node -p "require('./package.json').name") |
| 143 | + if npm view "$PACKAGE_NAME@$VERSION" > /dev/null 2>&1; then |
| 144 | + echo "Version $VERSION of package $PACKAGE_NAME is already published. Skipping publish." |
| 145 | + else |
| 146 | + echo "Publishing version $VERSION of package $PACKAGE_NAME to NPM." |
| 147 | + npm publish --provenance |
| 148 | + fi |
| 149 | +
|
135 | 150 | - if: failure() # Only, on failure, send a message on the 94_bot-failing-ci Slack channel |
136 | 151 | name: Report workflow run status to Slack |
137 | 152 | uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 # v3.15.1 |
|
0 commit comments