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 }} 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 }}