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

[ci] Add release automation scripts #141

Merged
merged 2 commits into from
Oct 17, 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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,31 @@ jobs:
run: yarn run lint
- name: Prettier
run: yarn run prettier-check

release:
name: Publish to NPM
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'relayjs/eslint-plugin-relay'
needs: [build, lint]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'yarn'
- name: Build latest (main) version
if: github.ref == 'refs/heads/main'
run: yarn version --no-git-tag-version --new-version 0.0.0-main-${GITHUB_SHA}
Copy link
Contributor Author

@alloy alloy Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, if this is a push to the main branch, this will update the version in package.json to be a prerelease with the latest commit SHA.

- name: Check release version matches tag
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if this is a push to a tag, then check that the tag matches the value of the version in package.json.

run: |
if [ $(cat package.json | jq -r '.version') != "${GITHUB_REF_NAME:1}" ]; then
echo "Version in package.json does not match tag. Did you forget to commit the package.json version bump?"
exit 1
fi
- name: Publish to npm
if: github.ref == 'refs/heads/main' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
run: npm publish ${TAG}
env:
TAG: ${{ github.ref == 'refs/heads/main' && '--tag=main' || ((contains(github.ref_name, '-rc.') && '--tag=dev') || '' )}}
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then finally the package gets published.

10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ _Before_ submitting a pull request, please make sure the following is done…
4. Auto-format the code by running `yarn run prettier` or `npm run prettier`.
5. If you haven't already, complete the CLA.

### Package Publishing

- Every change that gets pushed to the `main` branch will be published as `0.0.0-main-SHA`.
- For stable releases, the release author is expected to update the version in `package.json`, commit that, and create an accompanying tag. Once this is pushed a package will be published following that version. The workflow would look something like this:

```bash
$ yarn version --minor
$ git push --follow-tags
```

### Contributor License Agreement (CLA)

In order to accept your pull request, we need you to submit a CLA. You only need to do this once, so if you've done this for another Facebook open source project, you're good to go. If you are submitting a pull request for the first time, just let us know that you have completed the CLA and we can cross-check with your GitHub username.
Expand Down
Loading