Skip to content

Commit

Permalink
Feat/ags GitHub action (#30)
Browse files Browse the repository at this point in the history
* add wf to check ags version

* add build and release ci
  • Loading branch information
jamesholcombe authored Oct 26, 2024
1 parent af65146 commit bd6f492
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/check-ags-lib-version.yml
Original file line number Diff line number Diff line change
@@ -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 }}
47 changes: 47 additions & 0 deletions .github/workflows/publish-and-release-ags-lib.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit bd6f492

Please sign in to comment.