diff --git a/.github/workflows/gh-pr-create.yml b/.github/workflows/gh-pr-create.yml new file mode 100644 index 0000000..d5778bb --- /dev/null +++ b/.github/workflows/gh-pr-create.yml @@ -0,0 +1,46 @@ +name: gh pr create +on: + push: + branches: "main" + paths-ignore: + - README.md + - LICENSE + - .gitignore + - .github/** + - "!.github/workflows/gh-pr-create.yml" + schedule: + - cron: "41 */6 * * *" + workflow_dispatch: +concurrency: ${{ github.workflow }} +jobs: + gh-pr-create: + permissions: + contents: write + pull-requests: write + runs-on: windows-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions4git/setup-git@v1 + - uses: actions/setup-node@v4 + with: + node-version: "lts/*" + cache: npm + - run: npm ci + - run: npm run generate + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - run: | + branch="generate-$(jq -r '.version' package.json)" + if git rev-parse --verify "$branch"; then + git checkout -b "$branch" + git add -A && git commit -m 'Automated changes' + git push -u origin "$branch" + gh pr create --fill + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/npm-generate.yml b/.github/workflows/npm-generate.yml deleted file mode 100644 index 87321d0..0000000 --- a/.github/workflows/npm-generate.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: npm generate -on: - push: - branches: "main" - paths-ignore: - - README.md - - LICENSE - - .gitignore - - .github/** - - "!.github/workflows/npm-generate.yml" - schedule: - - cron: "41 */6 * * *" - workflow_dispatch: -concurrency: ${{ github.workflow }} -jobs: - npm-generate: - permissions: - contents: write - outputs: - pushed: ${{ steps.add-commit-push.outputs.pushed }} - runs-on: windows-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: "lts/*" - cache: npm - - run: npm ci - - run: npm run generate - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: npm test - - id: add-commit-push - run: | - git config --global user.name "actions[bot]" - git config --global user.email "actions@github.com" - git add -A - if git commit -m "Automated changes"; then - git push -u origin main - echo "pushed=true" >> "$GITHUB_OUTPUT" - else - echo "pushed=false" >> "$GITHUB_OUTPUT" - fi - gh-release-create: - needs: npm-generate - if: fromJSON(needs.npm-generate.outputs.pushed) - permissions: - contents: write - runs-on: windows-latest - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: "lts/*" - cache: npm - - run: | - version=$(jq -r .version package.json) - gh release create "v$version" --generate-notes - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - npm-publish: - needs: gh-release-create - uses: ./.github/workflows/npm-publish.yml - secrets: inherit diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 997d133..07fc537 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -3,8 +3,7 @@ on: release: types: released workflow_dispatch: - workflow_call: -concurrency: ${{ github.workflow }}-npm-publish +concurrency: ${{ github.workflow }} jobs: npm-publish: runs-on: windows-latest diff --git a/run.js b/run.js index efc12ec..8fd5d20 100644 --- a/run.js +++ b/run.js @@ -32,7 +32,7 @@ async function generate() { console.log("updated package.json version to %o", newVersion); } - const gfwVersion = package_.version.split("+")[1]; + const gfwVersion = remoteGfwVersion; const gitVersion = gfwVersion.match(/^\d+\.\d+\.\d+/)[0]; console.debug("gfw version %o", gfwVersion); console.debug("git version %o", gitVersion);