Skip to content

Commit 187e7eb

Browse files
authored
fix: changeset configuration and github action (#1590)
* updated commit for changeset config * updated changeset github workflow * updated version command in changeset action
1 parent f61e8ed commit 187e7eb

6 files changed

+18
-287
lines changed

.github/workflows/if-nodejs-release.yml

-134
This file was deleted.

.github/workflows/if-nodejs-version-bump.yml

-69
This file was deleted.

.github/workflows/release-with-changesets.yml

+3-41
Original file line numberDiff line numberDiff line change
@@ -108,54 +108,16 @@ jobs:
108108
shell: bash
109109
# This step can be removed once the issue is fixed in the changeset package.
110110
run: npm install @changesets/[email protected]
111-
- if: steps.packagejson.outputs.exists == 'true'
112-
name: Get version update from the changeset
113-
uses: changesets/action@v1
114-
with:
115-
version: npx -p @changesets/[email protected] changeset version
116-
commit: "chore(release): release and bump versions of packages"
117-
title: "chore(release): release and bump versions of packages"
118-
env:
119-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
120-
GIT_AUTHOR_NAME: asyncapi-bot
121-
GIT_AUTHOR_EMAIL: [email protected]
122-
GIT_COMMITTER_NAME: asyncapi-bot
123-
GIT_COMMITTER_EMAIL: [email protected]
124-
125-
- if: steps.packagejson.outputs.exists == 'true'
126-
name: Get version from package.json
127-
id: get-version
128-
run: echo ::set-output name=version::$(node -p "require('./package.json').version")
129-
130-
- if: steps.packagejson.outputs.exists == 'true'
131-
name: Update version inside action.yml
132-
uses: actions/github-script@v6
133-
with:
134-
script: |
135-
const fs = require('fs');
136-
const path = require('path');
137-
138-
const templatePath = path.resolve('./', 'action-template.yml');
139-
const outputPath = path.resolve('./', 'action.yml');
140-
141-
const templateContent = fs.readFileSync(templatePath, 'utf8');
142-
const updatedContent = templateContent.replace(/\${ version }/g, '${{ steps.get-version.outputs.version }}');
143-
144-
fs.writeFileSync(outputPath, updatedContent, 'utf8');
145-
console.log(`Updated action.yml with version ${{ steps.get-version.outputs.version }}`);
146-
147-
- if: steps.packagejson.outputs.exists == 'true'
148-
name: Commit changes of action.yml
149-
run: |
150-
git commit -am "chore(release): release and bump versions of github action docker"
151-
git push --set-upstream origin ${GITHUB_REF#refs/heads/} || git push origin ${GITHUB_REF#refs/heads/}
152111

153112
- if: steps.packagejson.outputs.exists == 'true'
154113
name: Publish to any of NPM, Github, and Docker Hub
155114
#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
156115
uses: changesets/action@v1
157116
id: release
158117
with:
118+
version: npm run bump:version
119+
commit: "chore(release): release and bump versions of packages"
120+
title: "chore(release): release and bump versions of packages"
159121
publish: npx -p @changesets/[email protected] changeset publish
160122
setupGitUser: false
161123
env:

.releaserc

-24
This file was deleted.
+13-17
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
const fs = require('fs');
22
const path = require('path');
33

4-
module.exports = {
5-
prepare: async (pluginConfig, context) => {
6-
const { nextRelease } = context;
7-
const version = nextRelease.version;
4+
function bumpActionVersion() {
5+
const packageJsonPath = path.join(__dirname, '../../', 'package.json');
6+
const packageJsonVersion = require(packageJsonPath).version;
87

9-
const templatePath = path.resolve(__dirname, '../../', 'action-template.yml');
10-
const outputPath = path.resolve(__dirname, '../../', 'action.yml');
8+
const templatePath = path.join(__dirname, '../../', 'action-template.yml');
9+
const outputPath = path.join(__dirname, '../../', 'action.yml');
1110

12-
try {
13-
const templateContent = fs.readFileSync(templatePath, 'utf8');
14-
const updatedContent = templateContent.replace(/\${ version }/g, version);
15-
fs.writeFileSync(outputPath, updatedContent, 'utf8');
16-
console.log(`Updated action.yml with version ${version}`);
17-
} catch (error) {
18-
console.error('Error updating action.yml:', error);
19-
throw error;
20-
}
21-
}
22-
};
11+
const templateContent = fs.readFileSync(templatePath, 'utf8');
12+
const updatedContent = templateContent.replace(/\${ version }/g, packageJsonVersion);
13+
14+
fs.writeFileSync(outputPath, updatedContent, 'utf8');
15+
console.log(`Updated action.yml with version ${packageJsonVersion}`);
16+
}
17+
18+
bumpActionVersion();

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@
142142
"repository": "asyncapi/cli",
143143
"scripts": {
144144
"build": "rimraf lib && node scripts/fetch-asyncapi-example.js && tsc && oclif manifest && echo \"Build Completed\"",
145-
"bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION",
145+
"bump:github-action": "cd github-action/lib/ && node bump-action-version.js",
146+
"bump:version": "npx -p @changesets/[email protected] changeset version && npm run bump:github-action",
146147
"dev": "tsc --watch",
147148
"docker:build": "docker build -t asyncapi/cli:latest .",
148149
"generate:readme:create": "node -e \"const fs = require('fs'); fs.writeFileSync('scripts/README.md', '# Usage\\n\\n<!-- usage -->\\n\\n# Commands\\n\\n<!-- commands -->\\n');\"",
@@ -169,7 +170,6 @@
169170
"createhook": "oclif generate hook myhook --event=command_not_found",
170171
"createhookinit": "oclif generate hook inithook --event=init",
171172
"action:docker:build": "docker build -f github-action/Dockerfile -t asyncapi/github-action-for-cli:latest .",
172-
"action:bump:version": "npm --no-git-tag-version --allow-same-version version $VERSION",
173173
"action:test": "cd github-action && make test"
174174
},
175175
"types": "lib/index.d.ts"

0 commit comments

Comments
 (0)