From 5637768a79c081dbca190bad6f7d50e25b02b1e5 Mon Sep 17 00:00:00 2001 From: James Holcombe Date: Sat, 26 Oct 2024 16:03:19 +0100 Subject: [PATCH 1/5] add wf to check ags version --- .github/workflows/check-ags-lib-version.yml | 43 +++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/check-ags-lib-version.yml diff --git a/.github/workflows/check-ags-lib-version.yml b/.github/workflows/check-ags-lib-version.yml new file mode 100644 index 0000000..572b074 --- /dev/null +++ b/.github/workflows/check-ags-lib-version.yml @@ -0,0 +1,43 @@ +name: Check AGS Package Version + +on: + pull_request: + paths: + - 'ags/**' # Trigger only if files in the `ags` package have changed + +jobs: + check_version: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Get current branch version of ags package + id: current_version + run: | + jq -r '.version' ags/package.json > current_version.txt + echo "current_version=$(cat current_version.txt)" >> $GITHUB_ENV + + - name: Get main branch version of ags package + run: | + git fetch origin main + git show origin/main:ags/package.json | jq -r '.version' > main_version.txt + echo "main_version=$(cat main_version.txt)" >> $GITHUB_ENV + + - name: Check for changes in the ags package + id: check_changes + run: | + if git diff --quiet origin/main -- ags/; then + echo "has_changes=false" >> $GITHUB_ENV + else + echo "has_changes=true" >> $GITHUB_ENV + fi + + - name: Fail if version is not updated + if: env.has_changes == 'true' && env.current_version == env.main_version + run: | + echo "Code has changed in the ags package, but the version has not been updated." + exit 1 + env: + current_version: ${{ env.current_version }} + main_version: ${{ env.main_version }} From cb1b5a51a1679cbf78e2f1398db7a1037b9d9eb6 Mon Sep 17 00:00:00 2001 From: James Holcombe Date: Sat, 26 Oct 2024 16:07:53 +0100 Subject: [PATCH 2/5] add build and release ci --- .../workflows/publish-and-release-ags-lib.yml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/publish-and-release-ags-lib.yml diff --git a/.github/workflows/publish-and-release-ags-lib.yml b/.github/workflows/publish-and-release-ags-lib.yml new file mode 100644 index 0000000..3841cfa --- /dev/null +++ b/.github/workflows/publish-and-release-ags-lib.yml @@ -0,0 +1,47 @@ +name: Publish and Release AGS Package + +on: + push: + branches: + - main + +jobs: + publish_npm: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Get version of the ags package + id: get_version + run: | + VERSION=$(jq -r '.version' ags/package.json) + echo "ags_version=$VERSION" >> $GITHUB_ENV + + - name: Publish ags package to npm + run: npm publish --workspace ags + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + if: contains(github.event.head_commit.message, 'chore(release)') + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + with: + tag_name: "ags-v${{ env.ags_version }}" + release_name: "AGS Library v${{ env.ags_version }}" + body: | + Release of version ${{ env.ags_version }} of the AGS library. + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a8b97a61d3d3c1359b503adfa569ee96e685c607 Mon Sep 17 00:00:00 2001 From: James Holcombe Date: Sat, 26 Oct 2024 16:25:53 +0100 Subject: [PATCH 3/5] bump ags version --- .github/workflows/publish-and-release-ags-lib.yml | 2 +- ags/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-and-release-ags-lib.yml b/.github/workflows/publish-and-release-ags-lib.yml index 3841cfa..d613d8d 100644 --- a/.github/workflows/publish-and-release-ags-lib.yml +++ b/.github/workflows/publish-and-release-ags-lib.yml @@ -35,7 +35,7 @@ jobs: - name: Create GitHub Release id: create_release - uses: actions/create-release@v1 + uses: actions/create-release@v2 with: tag_name: "ags-v${{ env.ags_version }}" release_name: "AGS Library v${{ env.ags_version }}" diff --git a/ags/package.json b/ags/package.json index c1bfb64..60e3ccf 100644 --- a/ags/package.json +++ b/ags/package.json @@ -1,6 +1,6 @@ { "name": "@groundup-dev/ags", - "version": "0.1.0", + "version": "0.1.1", "type": "module", "main": "./dist/index.js", "module": "./dist/index.js", From 375bdaed836d1a3b9789f4806021b85c79925d6b Mon Sep 17 00:00:00 2001 From: James Holcombe Date: Sat, 26 Oct 2024 16:38:21 +0100 Subject: [PATCH 4/5] remove github release --- .github/workflows/publish-and-release-ags-lib.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/publish-and-release-ags-lib.yml b/.github/workflows/publish-and-release-ags-lib.yml index d613d8d..65aa647 100644 --- a/.github/workflows/publish-and-release-ags-lib.yml +++ b/.github/workflows/publish-and-release-ags-lib.yml @@ -33,15 +33,4 @@ jobs: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} if: contains(github.event.head_commit.message, 'chore(release)') - - name: Create GitHub Release - id: create_release - uses: actions/create-release@v2 - with: - tag_name: "ags-v${{ env.ags_version }}" - release_name: "AGS Library v${{ env.ags_version }}" - body: | - Release of version ${{ env.ags_version }} of the AGS library. - draft: false - prerelease: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + \ No newline at end of file From 2bc9b39c5a59f1875b61462fd6a31aa87bafa5fd Mon Sep 17 00:00:00 2001 From: James Holcombe Date: Sat, 26 Oct 2024 16:43:07 +0100 Subject: [PATCH 5/5] make only publish if changed ags --- .github/workflows/publish-and-release-ags-lib.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-and-release-ags-lib.yml b/.github/workflows/publish-and-release-ags-lib.yml index 24d7dc1..29957c8 100644 --- a/.github/workflows/publish-and-release-ags-lib.yml +++ b/.github/workflows/publish-and-release-ags-lib.yml @@ -4,6 +4,8 @@ on: push: branches: - main + paths: + - 'ags/**' # Trigger only if files in the `ags` package have changed jobs: publish_npm: