Skip to content

Commit

Permalink
Merge pull request #1 from divinetettey/557-auto-increment-version
Browse files Browse the repository at this point in the history
557 auto increment version - test
  • Loading branch information
divinetettey authored Jun 20, 2024
2 parents ee4eecd + 778c12f commit 0be28b9
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 57 deletions.
164 changes: 107 additions & 57 deletions .github/workflows/release.yml
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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.data
logs
*.log
.idea
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand Down

0 comments on commit 0be28b9

Please sign in to comment.