diff --git a/.github/workflows/publish-package-github.yml b/.github/workflows/publish-package-github.yml new file mode 100644 index 0000000..087676b --- /dev/null +++ b/.github/workflows/publish-package-github.yml @@ -0,0 +1,47 @@ +name: Publish to GitHub Packages + +on: + push: + paths: "package.json" + +jobs: + publish-gpr: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + submodules: true + - name: Configure Git + run: | + git config --global user.email "280145668@qq.com" + git config --global user.name "xiangnanscu-ci" + - uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + registry-url: https://npm.pkg.github.com/ + - name: Install jq + run: sudo apt-get install jq + - name: Check if version changed + id: version_changed + run: | + VERSION_OLD=$(git show ${{ github.event.before }}:package.json | jq -r .version) + VERSION_NEW=$(jq -r .version package.json) + if [ "$VERSION_OLD" != "$VERSION_NEW" ]; then + echo "Version changed from $VERSION_OLD to $VERSION_NEW" + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "Version did not change" + echo "changed=false" >> $GITHUB_OUTPUT + fi + - name: Publish to github + if: steps.version_changed.outputs.changed == 'true' + run: | + corepack enable + npm i + npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/publish-package-npm.yml b/.github/workflows/publish-package-npm.yml index f080330..3f5f93a 100644 --- a/.github/workflows/publish-package-npm.yml +++ b/.github/workflows/publish-package-npm.yml @@ -18,7 +18,7 @@ jobs: - name: Configure Git run: | git config --global user.email "280145668@qq.com" - git config --global user.name "xiangnanscu" + git config --global user.name "xiangnanscu-ci" - uses: actions/setup-node@v4 with: node-version-file: ".nvmrc" diff --git a/package.json b/package.json index 802ff81..498694e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xiangnanscu/lua2js", - "version": "0.24.0", + "version": "0.25.0", "main": "src/lua2js.mjs", "type": "module", "bin": {