From 66fbfd4158bc2b9f2d4a9bf26c8f56550ff8152d Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 20 Nov 2024 11:58:24 +1300 Subject: [PATCH] fix: implement github actions automated deployment on merge --- .github/workflows/release.yml | 10 +++++++++- .releaserc.json | 3 ++- package-release.sh | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100755 package-release.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c82280..a6f2792 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Configure git user + run: | + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" - name: Tag semantic release id: tag uses: pixelfusion/actions/tag@v1 - + - name: Run release + shell: bash + run: make release + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.releaserc.json b/.releaserc.json index 9c789e6..78a1a4d 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -10,7 +10,8 @@ [ "@semantic-release/exec", { - "successCmd": "echo '${nextRelease.gitTag}' > version.txt" + "successCmd": "echo '${nextRelease.gitTag}' > version.txt", + "prepareCmd": "./package-release.sh ${nextRelease.version}" } ] ] diff --git a/package-release.sh b/package-release.sh new file mode 100755 index 0000000..68216b7 --- /dev/null +++ b/package-release.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Check if a version parameter is provided +if [ $# -eq 0 ]; then + echo "Error: Version parameter is missing." + exit 1 +fi + +# Store the version parameter +version=$1 + +# Update package.json with the provided version +jq --arg version "$version" '.version = $version' gatsby-plugin-s3/package.json > gatsby-plugin-s3/package-temp.json +mv gatsby-plugin-s3/package-temp.json gatsby-plugin-s3/package.json + +# Commit the package.json changes +git add gatsby-plugin-s3/package.json +git commit -m "chore: update package.json version to $version" + +# Push the changes to origin +git push origin + +echo "Package version updated successfully to $version and changes pushed to origin."