Skip to content

Commit 9da2ac0

Browse files
authored
new: Support proto lockfiles. (#26)
1 parent 70843c5 commit 9da2ac0

4 files changed

Lines changed: 39 additions & 41 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.5.0
2+
3+
- Support proto v0.51 changes and `.protolock` files.
4+
- Fixed the proto/moon versions not being available in the post-run cache key.
5+
- Updated dependencies.
6+
17
# 0.4.1
28

39
- Include the architecture in the cache key.

helpers.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,24 @@ export function extractMajorMinor(version: string) {
9393
}
9494

9595
export function getCacheKeyPrefix() {
96-
// v1 - Before proto v0.24 changes
97-
return 'moonrepo-toolchain-v2';
96+
// v2 - Before proto v0.24 changes
97+
// v3 - proto v0.51 lockfile changes
98+
return 'moonrepo-toolchain-v3';
9899
}
99100

100101
export async function getToolchainCacheKey() {
101102
const hasher = crypto.createHash('sha1');
102-
const files = ['.prototools'];
103+
const files = ['.prototools', '.protolock'];
103104

104105
if (isUsingMoon()) {
105106
const root = core.getInput('workspace-root');
106107

107108
if (root) {
108-
files.push(path.join(root, '.prototools'), path.join(root, '.moon/toolchain.yml'));
109+
files.push(
110+
path.join(root, '.prototools'),
111+
path.join(root, '.protolock'),
112+
path.join(root, '.moon/toolchain.yml'),
113+
);
109114
} else {
110115
files.push('.moon/toolchain.yml');
111116
}
@@ -115,15 +120,15 @@ export async function getToolchainCacheKey() {
115120

116121
hasher.update(await glob.hashFiles(files.join('\n')));
117122

118-
const protoVersion = process.env.PROTO_CLI_VERSION;
123+
const protoVersion = process.env.PROTO_CLI_VERSION ?? core.getState('PROTO_CLI_VERSION');
119124

120125
if (protoVersion) {
121126
core.debug(`Hashing proto version: ${protoVersion}`);
122127

123128
hasher.update(extractMajorMinor(protoVersion));
124129
}
125130

126-
const moonVersion = process.env.MOON_CLI_VERSION;
131+
const moonVersion = process.env.MOON_CLI_VERSION ?? core.getState('MOON_CLI_VERSION');
127132

128133
if (moonVersion) {
129134
core.debug(`Hashing moon version: ${moonVersion}`);
@@ -185,8 +190,11 @@ export async function installBin(bin: string) {
185190
const result = await execa(binPath, ['--version'], { stdio: 'pipe' });
186191

187192
if (result.stdout) {
193+
const v = result.stdout.replace(bin, '').trim();
194+
188195
// eslint-disable-next-line require-atomic-updates
189-
process.env[`${envPrefix}_CLI_VERSION`] = result.stdout.replace(bin, '').trim();
196+
process.env[`${envPrefix}_CLI_VERSION`] = v;
197+
core.saveState(`${envPrefix}_CLI_VERSION`, v);
190198

191199
core.info(result.stdout);
192200
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@moonrepo/setup-toolchain",
3-
"version": "0.4.1",
3+
"version": "0.5.0",
44
"description": "A GitHub action to setup and cache the proto and moon toolchains.",
55
"main": "dist/index.js",
66
"scripts": {
@@ -19,10 +19,10 @@
1919
"author": "Miles Johnson",
2020
"license": "MIT",
2121
"dependencies": {
22-
"@actions/cache": "^4.0.2",
23-
"@actions/core": "^1.10.1",
22+
"@actions/cache": "^4.0.3",
23+
"@actions/core": "^1.11.1",
2424
"@actions/glob": "^0.5.0",
25-
"@actions/tool-cache": "^2.0.1",
25+
"@actions/tool-cache": "^2.0.2",
2626
"execa": "^5.1.1"
2727
},
2828
"devDependencies": {

pnpm-lock.yaml

Lines changed: 14 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)