Skip to content

Commit

Permalink
updated release workflow with changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
akshatnema committed Dec 6, 2024
1 parent 83ec053 commit 1f41af9
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions .github/workflows/release-with-changesets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 1f41af9

Please sign in to comment.