From a3e29e073d6ba9a8d2b735bc06c8585fa9f4a604 Mon Sep 17 00:00:00 2001 From: Divine Tettey Date: Mon, 3 Jun 2024 10:56:47 +0000 Subject: [PATCH 1/7] ci(release): adding a release to automatically increment version in package.json on new release --- .github/workflows/release.yml | 145 +++++++++++++++++++++------------- .gitignore | 1 + 2 files changed, 89 insertions(+), 57 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 97af688ee..6bb1519db 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,60 +1,91 @@ -# --- -# 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: + 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 }} + update_version: + needs: create_npm_release + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v6 + id: release-drafter + with: + publish: true + - name: Extract version + id: extract_version + run: | + echo "${{ steps.release-drafter.outputs.tag_name }}" | sed 's/^v//' > version.txt + echo ::set-output name=version::$(cat version.txt) + - name: Update package.json and package-lock version + run : | + jq --arg version "${{ steps.extract_version.outputs.version }}" '.version = $version' package.json > package_tmp.json && mv package_tmp.json package.json + jq --arg version "${{ steps.extract_version.outputs.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: | + sed -i "s/version: '.*'/version: '${{ steps.extract_version.outputs.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 config --global push.default current + git add package.json package-lock.json + git commit -m "chore: update version to ${{ steps.extract_version.outputs.version }}" + - name: Push Changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 1849589c4..f963c676f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .data logs *.log +.idea npm-debug.log* yarn-debug.log* yarn-error.log* From 54a7efe02b3de7f280b4faaede504440dd1ab437 Mon Sep 17 00:00:00 2001 From: Divine Tettey Date: Fri, 7 Jun 2024 16:02:51 +0000 Subject: [PATCH 2/7] ci(release): add checkout step to release workflow --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6bb1519db..2cd5a898f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,6 +62,7 @@ jobs: needs: create_npm_release runs-on: ubuntu-latest steps: + - uses: actions/checkout@8459bc0 # v4 - uses: release-drafter/release-drafter@v6 id: release-drafter with: From d6bcfa4d3ce6e7814c57ea7eab6b27e9e5f29379 Mon Sep 17 00:00:00 2001 From: Divine Tettey Date: Thu, 20 Jun 2024 09:59:16 +0000 Subject: [PATCH 3/7] ci(release): move version update to run before releases --- .github/workflows/release.yml | 84 +++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2cd5a898f..4b3966c02 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,57 @@ permissions: contents: read 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 }}" + + - 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 }} @@ -57,36 +107,4 @@ jobs: - run: npm ci - run: npm publish --access=public env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - update_version: - needs: create_npm_release - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8459bc0 # v4 - - uses: release-drafter/release-drafter@v6 - id: release-drafter - with: - publish: true - - name: Extract version - id: extract_version - run: | - echo "${{ steps.release-drafter.outputs.tag_name }}" | sed 's/^v//' > version.txt - echo ::set-output name=version::$(cat version.txt) - - name: Update package.json and package-lock version - run : | - jq --arg version "${{ steps.extract_version.outputs.version }}" '.version = $version' package.json > package_tmp.json && mv package_tmp.json package.json - jq --arg version "${{ steps.extract_version.outputs.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: | - sed -i "s/version: '.*'/version: '${{ steps.extract_version.outputs.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 config --global push.default current - git add package.json package-lock.json - git commit -m "chore: update version to ${{ steps.extract_version.outputs.version }}" - - name: Push Changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file From 778c12f1cf2272bcde2fcfd0a9ad688dc834d02f Mon Sep 17 00:00:00 2001 From: Jamie Slome Date: Thu, 20 Jun 2024 15:58:05 +0100 Subject: [PATCH 4/7] Update .github/workflows/release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b3966c02..444205d76 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,7 +62,7 @@ jobs: 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 }}" + git commit -m "chore: update version to ${{ steps.extract_version.outputs.version }} [skip ci]" - name: Push Changes uses: ad-m/github-push-action@master From b7b8a11b090d46632be7beee788519221b9f2478 Mon Sep 17 00:00:00 2001 From: Divine Sedem Tettey <128141225+divinetettey@users.noreply.github.com> Date: Thu, 20 Jun 2024 17:33:04 +0000 Subject: [PATCH 5/7] Revert "557 auto increment version - test" --- .github/workflows/release.yml | 164 ++++++++++++---------------------- .gitignore | 1 - 2 files changed, 57 insertions(+), 108 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 444205d76..97af688ee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,110 +1,60 @@ ---- -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: - 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 }} \ No newline at end of file +# 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 }} diff --git a/.gitignore b/.gitignore index f963c676f..1849589c4 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ .data logs *.log -.idea npm-debug.log* yarn-debug.log* yarn-error.log* From 499969adbd43c12d0e22f999630dafbbb44cd7b0 Mon Sep 17 00:00:00 2001 From: Divine Tettey Date: Fri, 21 Jun 2024 10:48:47 +0000 Subject: [PATCH 6/7] ci(release): improvements to update_version workflow --- .github/workflows/release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 444205d76..ce04877c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,8 @@ permissions: jobs: update_version: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout repository uses: actions/checkout@v4 @@ -38,8 +40,7 @@ jobs: echo "Version is empty. Exiting" exit 1 fi - echo "$version" > version.txt - echo ::set-output name=version::$version + echo "version=$version" >> $GITHUB_OUTPUT - name: Update package.json and package-lock.json version run: VERSION=${{ steps.extract_version.outputs.version }} From 111457ff0f48eae81bbc5acb37689003734f2cdb Mon Sep 17 00:00:00 2001 From: Divine Tettey Date: Thu, 4 Jul 2024 09:30:33 +0000 Subject: [PATCH 7/7] ci(release): add npm install step to release workflow --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce04877c3..279ba417b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,7 +49,8 @@ jobs: 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: NPM Install + run: npm install - name: Update docusaurus.config.js version run: | VERSION=${{ steps.extract_version.outputs.version }}