-
Notifications
You must be signed in to change notification settings - Fork 130
chore: automatically increment version in package.json on new release #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
divinetettey
wants to merge
22
commits into
finos:main
Choose a base branch
from
divinetettey:557-auto-increment-version
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a3e29e0
ci(release): adding a release to automatically increment version in p…
divinecodes 54a7efe
ci(release): add checkout step to release workflow
divinetettey cae8f79
Merge branch 'main' into 557-auto-increment-version
divinetettey 663e030
Merge branch 'main' into 557-auto-increment-version
divinetettey bbf6e0f
Merge branch 'main' into 557-auto-increment-version
divinetettey 3e29af9
Merge branch 'main' into 557-auto-increment-version
divinetettey 5f26b95
Merge branch 'main' into 557-auto-increment-version
divinetettey d6bcfa4
ci(release): move version update to run before releases
divinetettey 778c12f
Update .github/workflows/release.yml
JamieSlome 0be28b9
Merge pull request #1 from divinetettey/557-auto-increment-version
divinetettey b7b8a11
Revert "557 auto increment version - test"
divinetettey 3cb7cd5
Merge pull request #2 from divinetettey/revert-1-557-auto-increment-v…
divinetettey 499969a
ci(release): improvements to update_version workflow
divinetettey 1027f2e
Merge branch 'main' into 557-auto-increment-version
divinetettey a69cdde
Merge branch 'main' into 557-auto-increment-version
JamieSlome c357671
Merge branch 'main' into 557-auto-increment-version
divinetettey 7fbc690
Merge branch 'main' into 557-auto-increment-version
JamieSlome e4b400d
Merge branch 'main' into 557-auto-increment-version
JamieSlome 3ef3465
Merge branch 'main' into 557-auto-increment-version
divinetettey 111457f
ci(release): add npm install step to release workflow
divinetettey 9d9db92
Merge branch 'main' into 557-auto-increment-version
JamieSlome 6b86691
Merge branch 'main' into 557-auto-increment-version
JamieSlome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
@@ -1,60 +1,112 @@ | ||
# --- | ||
# name: Release | ||
--- | ||
name: Release | ||
|
||
# on: | ||
# workflow_dispatch: | ||
# push: | ||
# branches: | ||
# - main | ||
# paths: | ||
# - 'src/**' | ||
# - 'test/**' | ||
# - 'scripts/**' | ||
# - 'public/**' | ||
# - 'packages/**' | ||
# - 'package.json' | ||
# - 'package-lock.json' | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'src/**' | ||
- 'test/**' | ||
- 'scripts/**' | ||
- 'public/**' | ||
- 'packages/**' | ||
- 'package.json' | ||
- 'package-lock.json' | ||
|
||
# permissions: | ||
# contents: read | ||
permissions: | ||
contents: read | ||
|
||
# jobs: | ||
# create_github_release: | ||
# outputs: | ||
# full-tag: ${{ steps.release-drafter.outputs.tag_name }} | ||
# short-tag: ${{ steps.get_tag_name.outputs.SHORT_TAG }} | ||
# body: ${{ steps.release-drafter.outputs.body }} | ||
# runs-on: ubuntu-latest | ||
# permissions: | ||
# contents: write | ||
# pull-requests: read | ||
# steps: | ||
# - uses: release-drafter/release-drafter@v6 | ||
# id: release-drafter | ||
# env: | ||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# with: | ||
# publish: true | ||
# - name: Get the short tag | ||
# id: get_tag_name | ||
# run: | | ||
# short_tag=$(echo ${{ steps.release-drafter.outputs.tag_name }} | cut -d. -f1) | ||
# echo "SHORT_TAG=$short_tag" >> $GITHUB_OUTPUT | ||
# create_npm_release: | ||
# needs: create_github_release | ||
# runs-on: ubuntu-latest | ||
# permissions: | ||
# packages: write | ||
# env: | ||
# REGISTRY: ghcr.io | ||
# IMAGE_NAME: ${{ github.repository }} | ||
# steps: | ||
# - uses: actions/checkout@8459bc0 # v4 | ||
# - uses: actions/setup-node@c2ac33f # v4, Setup .npmrc file to publish to npm | ||
# with: | ||
# node-version: '18.x' | ||
# registry-url: 'https://registry.npmjs.org' | ||
# - run: npm ci | ||
# - run: npm publish --access=public | ||
# env: | ||
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
jobs: | ||
update_version: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Run Release Drafter | ||
uses: release-drafter/release-drafter@v6 | ||
id: release-drafter | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Extract Version | ||
id: extract_version | ||
run: | | ||
version="${{ steps.release-drafter.outputs.tag_name }}" | ||
version=$(echo "$version" || sed 's/^v//') | ||
if [ -z "$version"]; then | ||
echo "Version is empty. Exiting" | ||
exit 1 | ||
fi | ||
echo "version=$version" >> $GITHUB_OUTPUT | ||
- name: Update package.json and package-lock.json version | ||
run: | ||
VERSION=${{ steps.extract_version.outputs.version }} | ||
if [ -z "$version"]; then | ||
echo "Version is empty. Exiting" | ||
exit 1 | ||
fi | ||
jq --arg version "$VERSION" '.version = $version' package.json > package_tmp.json && mv package_tmp.json package.json | ||
- name: NPM Install | ||
run: npm install | ||
- name: Update docusaurus.config.js version | ||
run: | | ||
VERSION=${{ steps.extract_version.outputs.version }} | ||
if [ -z "$version"]; then | ||
echo "Version is empty. Exiting" | ||
exit 1 | ||
fi | ||
sed -i "s/version: '.*'/version: '$VERSION'/" website/docusaurus.config.js | ||
- name: Commit version change | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add package.json package-lock.json website/docusaurus.config.js | ||
git commit -m "chore: update version to ${{ steps.extract_version.outputs.version }} [skip ci]" | ||
|
||
- name: Push Changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
create_github_release: | ||
needs: update_version | ||
outputs: | ||
full-tag: ${{ steps.release-drafter.outputs.tag_name }} | ||
short-tag: ${{ steps.get_tag_name.outputs.SHORT_TAG }} | ||
body: ${{ steps.release-drafter.outputs.body }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: read | ||
steps: | ||
- uses: release-drafter/release-drafter@v6 | ||
id: release-drafter | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
publish: true | ||
- name: Get the short tag | ||
id: get_tag_name | ||
run: | | ||
short_tag=$(echo ${{ steps.release-drafter.outputs.tag_name }} | cut -d. -f1) | ||
echo "SHORT_TAG=$short_tag" >> $GITHUB_OUTPUT | ||
create_npm_release: | ||
needs: create_github_release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
steps: | ||
- uses: actions/checkout@8459bc0 # v4 | ||
- uses: actions/setup-node@c2ac33f # v4, Setup .npmrc file to publish to npm | ||
with: | ||
node-version: '18.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
- run: npm publish --access=public | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The echo
"$version" || sed 's/^v//
' statement is incorrect becauseecho
will always succeed, meaning thesed
command after||
will never execute. Instead, you should be using|
(pipe) instead of||
.