Skip to content

Commit

Permalink
Publish relay releases from github actions (#3669)
Browse files Browse the repository at this point in the history
Summary:
We already publishing all versions as `main` to NPM. Let's also integrate this process with our tags that we're using for releases.

- For all pushed commits to the `main` branch everything stays the same
- If a new tag is published, the action will build a release version (using a tag name)
- if GitHub tag contains `-rc.` suffix, `--tag=dev` will be used during `npm publish`.

Pull Request resolved: #3669

Test Plan:
Tested in different repo:
- verified that pushes to `main` repo published with `RELEASE_COMMIT_SHA`
- verified that `git push --tags` triggering `Build release version` job
- verified that `publish to npm` works and passed `--main` tag for pushes to `main` branch. `--dev` tag for tag pushes with `-rc.` string in the version, no tags for other versions

Verified locally:

  npm_package_version=v13.0.0-rc.0 yarn gulp release

works.

**Static Docs Preview: relay**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/1638559587/relay/)|

|**Modified Pages**|

Reviewed By: rbalicki2

Differential Revision: D32835517

Pulled By: alunyov

fbshipit-source-id: 15d207214216c4cf5aba3f36bfd0595cdd83119c
  • Loading branch information
alunyov authored and facebook-github-bot committed Dec 3, 2021
1 parent 66d0799 commit 08ea278
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
main-release:
name: Publish main tag to npm
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.repository == 'facebook/relay' && github.ref == 'refs/heads/main'
if: github.event_name == 'push' && github.repository == 'facebook/relay'
needs: [js-tests, js-lint, typecheck, rust-tests, build-compiler]
steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -138,12 +138,23 @@ jobs:
run: |
chmod +x linux-x64/relay
chmod +x macos-x64/relay
- name: Build main version
run: RELEASE_COMMIT_SHA=${{github.sha}} yarn gulp mainrelease
- name: Build latest (main) version
if: github.ref == 'refs/heads/main'
run: yarn gulp mainrelease
env:
RELEASE_COMMIT_SHA: ${{ github.sha }}

- name: Build release version
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
run: yarn gulp release

- name: Publish to npm
if: github.ref == 'refs/heads/main' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
run: |
for pkg in dist/*; do
npm publish "$pkg" --tag main
npm publish "$pkg" ${TAG}
done
env:
TAG: ${{ github.ref == 'refs/heads/main' && '--tag=main' || ((github.ref_type == 'tag' && startsWith(github.ref_name, 'v') && contains(github.ref_name, '-rc.') && '--tag=dev') || '' )}}
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,5 +404,6 @@ exports.clean = clean;
exports.dist = dist;
exports.watch = watch;
exports.mainrelease = gulp.series(cleanbuild, relayCompiler, setMainVersion);
exports.release = gulp.series(cleanbuild, relayCompiler);
exports.cleanbuild = cleanbuild;
exports.default = cleanbuild;

0 comments on commit 08ea278

Please sign in to comment.