Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PP-11314 add publishing workflow for release commits #6

Merged
merged 4 commits into from
Aug 23, 2023
Merged
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
Empty file.
29 changes: 29 additions & 0 deletions .github/workflows/prevent-merge-if-release-open.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check for unmerged release PR

on:
pull_request:

permissions:
pull-requests: read

jobs:
check_merge:
runs-on: ubuntu-latest
steps:
- name: Check for unmerged release
id: check_pr
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
})

const openRelease = prs.data.find(pr => pr.user.login === 'alphagov-pay-ci-concourse' && pr.state === 'open')

if (openRelease) {
core.setFailed(`There is an unmerged release PR, please merge it before merging this PR. \n Link: ${openRelease.url}`)
}
katstevens marked this conversation as resolved.
Show resolved Hide resolved
nlsteers marked this conversation as resolved.
Show resolved Hide resolved
34 changes: 34 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish to registry

on:
push:
branches:
- main

permissions:
contents: read

jobs:
tests:
uses: ./.github/workflows/run-tests.yml
publish:
needs: tests
runs-on: ubuntu-latest
if: "contains(github.event.head_commit.message, '[release]')"
katstevens marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: Setup Node
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c
with:
node-version-file: '.nvmrc'
cache: 'npm'
cache-dependency-path: 'package-lock.json'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Publish package
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
6 changes: 2 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Run Tests
name: Run tests

on:
pull_request:
push:
branches:
- main
nlsteers marked this conversation as resolved.
Show resolved Hide resolved
workflow_call:

permissions:
contents: read
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ For more examples of how metrics can be registered and used, see the [demo code]

`npm run demo` starts the ecs metadata stub and the demo express app

## Releasing

After a pull request is merged, Concourse will automatically create a new release pull request that increments the package version.

This pull request must be reviewed and merged by a developer.

Once the release pull request is merged, GitHub Actions will publish the new versioned package to NPM.

__IMPORTANT__: Other pull requests will be blocked from merging until the release pull request is merged or closed.

## Licence

[MIT License](LICENSE)
Expand Down