Skip to content

Commit

Permalink
Update Cargo.toml version when publishing main to NPM (#3709)
Browse files Browse the repository at this point in the history
Summary:
With this change the compiler in OSS will show the correct version:

Pull Request resolved: #3709

Test Plan:
Logs in the CI indicating the correct version:
```
   Compiling relay-compiler v0.0.0-main-0f540a5c (/home/runner/work/relay/relay/compiler/crates/relay-compiler)
```

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

|**Modified Pages**|

Reviewed By: rbalicki2

Differential Revision: D33352352

Pulled By: alunyov

fbshipit-source-id: 66419787971cb18e458dee271d54e6bc0c74972f
  • Loading branch information
alunyov authored and facebook-github-bot committed Dec 29, 2021
1 parent 75c04d0 commit b18251f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

0 comments on commit b18251f

Please sign in to comment.