diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba890943cefc8..467c56e6f4bfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,6 +105,19 @@ jobs: toolchain: stable override: true target: ${{ matrix.target.target }} + - uses: actions/setup-node@v2 + if: github.event_name == 'push' && github.repository == 'facebook/relay' && github.ref == 'refs/heads/main' + with: + node-version: 16.x + cache: 'yarn' + - name: Install dependencies + if: github.event_name == 'push' && github.repository == 'facebook/relay' && github.ref == 'refs/heads/main' + run: yarn install --frozen-lockfile --ignore-scripts + - name: Set the compiler version when releasing the `main` branch + if: github.event_name == 'push' && github.repository == 'facebook/relay' && github.ref == 'refs/heads/main' + run: yarn gulp setCompilerMainVersion + env: + RELEASE_COMMIT_SHA: ${{ github.sha }} - uses: actions-rs/cargo@v1 with: command: build diff --git a/gulpfile.js b/gulpfile.js index b81e1966b06c2..72a408f5a7336 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -389,6 +389,26 @@ const setMainVersion = async () => { }); }; +async function setCompilerMainVersion() { + if (!RELEASE_COMMIT_SHA) { + throw new Error('Expected the RELEASE_COMMIT_SHA env variable to be set.'); + } + const currentVersion = require('./package.json').version; + const compilerCargoFile = path.join( + '.', + 'compiler', + 'crates', + 'relay-compiler', + 'Cargo.toml', + ); + const cargo = fs.readFileSync(compilerCargoFile, 'utf8'); + const updatedCargo = cargo.replace( + `version = "${currentVersion}"`, + `version = "${VERSION}"`, + ); + fs.writeFileSync(compilerCargoFile, updatedCargo, 'utf8'); +} + const cleanbuild = gulp.series(clean, dist); exports.clean = clean; @@ -398,3 +418,4 @@ exports.mainrelease = gulp.series(cleanbuild, relayCompiler, setMainVersion); exports.release = gulp.series(cleanbuild, relayCompiler); exports.cleanbuild = cleanbuild; exports.default = cleanbuild; +exports.setCompilerMainVersion = setCompilerMainVersion;