-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated release workflow with changeset
- Loading branch information
1 parent
83ec053
commit 1f41af9
Showing
1 changed file
with
25 additions
and
6 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 |
---|---|---|
|
@@ -109,11 +109,24 @@ jobs: | |
# This step can be removed once the issue is fixed in the changeset package. | ||
run: npm install @changesets/[email protected] | ||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Get version from the changeset | ||
name: Get version update from the changeset | ||
uses: changesets/action@v1 | ||
id: get-version | ||
with: | ||
version: npx -p @changesets/[email protected] changeset version | ||
commit: "chore(release): release and bump versions of packages" | ||
title: "chore(release): release and bump versions of packages" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
GIT_AUTHOR_NAME: asyncapi-bot | ||
GIT_AUTHOR_EMAIL: [email protected] | ||
GIT_COMMITTER_NAME: asyncapi-bot | ||
GIT_COMMITTER_EMAIL: [email protected] | ||
|
||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Get version from package.json | ||
id: get-version | ||
run: echo ::set-output name=version::$(node -p "require('./package.json').version") | ||
|
||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Update version inside action.yml | ||
uses: actions/github-script@v6 | ||
|
@@ -122,21 +135,27 @@ jobs: | |
const fs = require('fs'); | ||
const path = require('path'); | ||
const templatePath = path.resolve(__dirname, '../../', 'action-template.yml'); | ||
const outputPath = path.resolve(__dirname, '../../', 'action.yml'); | ||
const templatePath = path.resolve('./', 'action-template.yml'); | ||
const outputPath = path.resolve('./', 'action.yml'); | ||
const templateContent = fs.readFileSync(templatePath, 'utf8'); | ||
const updatedContent = templateContent.replace(/\${ version }/g, '${{ steps.get-version.outputs.version }}'); | ||
fs.writeFileSync(outputPath, updatedContent, 'utf8'); | ||
console.log(`Updated action.yml with version ${{ steps.get-version.outputs.version }}`); | ||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Commit changes of action.yml | ||
run: | | ||
git commit -am "chore(release): release and bump versions of github action docker" | ||
git push --set-upstream origin ${GITHUB_REF#refs/heads/} || git push origin ${GITHUB_REF#refs/heads/} | ||
- if: steps.packagejson.outputs.exists == 'true' | ||
name: Publish to any of NPM, Github, and Docker Hub | ||
#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 | ||
uses: changesets/action@v1 | ||
id: release | ||
with: | ||
commit: "chore(release): release and bump versions of packages" | ||
title: "chore(release): release and bump versions of packages" | ||
publish: npx -p @changesets/[email protected] changeset publish | ||
setupGitUser: false | ||
env: | ||
|