Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/npm-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Use Node.js 18.17.1
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 18.17.1
- name: Install
Expand Down
50 changes: 38 additions & 12 deletions .github/workflows/publish-to-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,37 @@ on:
push:
branches: [ master ]

# Never run two publishes at once; a second merge waits for the first to finish
concurrency:
group: publish-to-npm
cancel-in-progress: false

permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.author.email, 'openactive-bot@users.noreply.github.com') }}
# Loop guard: the version bump commit below is pushed by the OpenActive GitHub App, and also carries [skip ci]
if: ${{ github.actor != 'openactive[bot]' }}

steps:
- name: Generate GitHub App Token
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
token: ${{ steps.generate-token.outputs.token }}
- name: Identify
run: |
git config user.name openactive-bot
git config user.email openactive-bot@users.noreply.github.com
git config --global user.name "openactive[bot]"
git config --global user.email 207210293+openactive[bot]@users.noreply.github.com
- name: Use Node.js 18.17.1
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 18.17.1
registry-url: https://registry.npmjs.org/
Expand All @@ -28,24 +43,35 @@ jobs:
- name: Test
run: npm test
- name: Increment Version
run: npm version patch
run: npm version patch -m "%s [skip ci]"
# Push before publishing: if the push is rejected, nothing is published, so npm can never get ahead of GitHub
- name: Push version update
run: git push origin HEAD:master
- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: Push version update
run: git push
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN2 }}

dispatch:
needs: publish
strategy:
fail-fast: false
matrix:
repo: ['OpenActive.NET', 'OpenActive.DatasetSite.NET', 'models-php', 'models-ruby', 'models-ts', 'data-model-validator-site', 'openactive.github.io', 'developer-documentation', 'openactive-test-suite']
runs-on: ubuntu-latest
steps:
# Without owner and repositories, the token only covers this repository and cannot dispatch to others
- name: Generate GitHub App Token
uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
owner: openactive
repositories: ${{ matrix.repo }}
- name: Trigger tooling update
uses: peter-evans/repository-dispatch@v1
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
token: ${{ steps.generate-token.outputs.token }}
repository: openactive/${{ matrix.repo }}
event-type: data-models-update
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"test": "npm run test-no-lint",
"test-no-lint": "jasmine",
"test-debug": "node --inspect-brk -i ./node_modules/jasmine/bin/jasmine.js",
"postpublish": "git push",
"publish-patch": "npm test && git pull && git push && npm version patch && npm publish"
"publish-patch": "npm test && git pull && npm version patch && git push && npm publish"
}
}
Loading