Skip to content
Open
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
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: https://registry.npmjs.org

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build package
run: npm run build

- name: Read package version
id: pkg
run: echo "version=$(node -p \"require('./package.json').version\")" >> "$GITHUB_OUTPUT"

- name: Check published version
id: published
run: |
PUBLISHED=$(npm view @wca/helpers version || echo "none")
echo "version=$PUBLISHED" >> "$GITHUB_OUTPUT"

- name: Create tag from package version
id: create_tag
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const version = '${{ steps.pkg.outputs.version }}';
const tag = `v${version}`;
const { owner, repo } = context.repo;

try {
await github.rest.git.getRef({ owner, repo, ref: `tags/${tag}` });
core.info(`Tag ${tag} already exists, skipping creation.`);
core.setOutput('created', 'false');
return;
} catch (error) {
if (error.status !== 404) throw error;
}

await github.rest.git.createRef({
owner,
repo,
ref: `refs/tags/${tag}`,
sha: context.sha,
});
core.info(`Created tag ${tag}.`);
core.setOutput('created', 'true');

- name: Publish to npm
if: steps.pkg.outputs.version != steps.published.outputs.version
run: npm publish --access public --provenance

- name: Create GitHub release
if: steps.create_tag.outputs.created == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.pkg.outputs.version }}
generate_release_notes: true
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WCA Helpers
\*\*\*\*# WCA Helpers

> Helpers and class definitions for WCA and WCIF

Expand All @@ -18,11 +18,18 @@ npm install @wca/helpers --save

## Development setup

## Meta
```sh
git clone
cd wca-helpers
npm install
npm run build
npm test
```

Distributed under the GPL license. See `LICENSE` for more information.
## Release process

[https://github.com/thewca/wca-helpers](https://github.com/thewca/wca-helpers)
- Create a new PR bumping `package.json` version (and update `CHANGELOG.md` if needed).
- Merge the change to `master`; the `Release` GitHub Action will run tests/build, create a tag `v<version>`, publish to npm, and generate a GitHub release.

## Contributing

Expand All @@ -31,3 +38,9 @@ Distributed under the GPL license. See `LICENSE` for more information.
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request

## Meta

Distributed under the GPL license. See `LICENSE` for more information.

[https://github.com/thewca/wca-helpers](https://github.com/thewca/wca-helpers)