-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from divinetettey/557-auto-increment-version
557 auto increment version - test
- Loading branch information
Showing
2 changed files
with
108 additions
and
57 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 |
---|---|---|
@@ -1,60 +1,110 @@ | ||
# --- | ||
# 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 | ||
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.txt | ||
echo ::set-output name=version::$version | ||
- 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 | ||
jq --arg version "$VERSION" '.version = $version' package-lock.json > package_lock_tmp.json && mv package_lock_tmp.json package-lock.json | ||
- 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 "action@github.com" | ||
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 }} |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
.data | ||
logs | ||
*.log | ||
.idea | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|