Skip to content

Commit fdb1d66

Browse files
coadofacebook-github-bot
authored andcommitted
Add create tag workflow for hermes-v1 (facebook#1816)
Summary: Adds `create-tag` workflow that will tag latest commit on releases. It is also possible to invoke this from GH UI for whatever reason with `release` type. Reviewed By: cipolleschi Differential Revision: D85255055
1 parent 83767e3 commit fdb1d66

File tree

3 files changed

+126
-45
lines changed

3 files changed

+126
-45
lines changed

.github/workflows/create-tag.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,47 @@ name: Publish Tag
22
on:
33
workflow_dispatch:
44
inputs:
5-
rnVersion:
6-
description: "The React Native version that will use this tag"
5+
release-type:
76
required: true
8-
targetSha:
9-
description: "The SHA you want to tag. If not specified it will tag the HEAD of the selected branch"
10-
required: false
7+
description: The type of release we are building. It could be commitly, release or dry-run
8+
type: choice
9+
options:
10+
- release
11+
- commitly
12+
- dry-run
13+
hermes-version:
14+
required: true
15+
description: The Hermes version to use for this tag
16+
type: string
17+
workflow_call:
18+
inputs:
19+
release-type:
20+
required: true
21+
description: The type of release we are building. It could be commitly, release or dry-run
22+
type: string
23+
hermes-version:
24+
required: true
25+
description: The Hermes version to use for this tag
26+
type: string
1127

1228
jobs:
1329
publish:
1430
runs-on: [ubuntu-latest]
15-
1631
steps:
17-
- name: Get current date
18-
id: date
19-
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
20-
21-
- name: Get the target SHA
22-
id: targetSha
23-
run: echo "targetSha=$(if [ -z "$TARGET_SHA" ]; then echo $GITHUB_SHA; else echo $TARGET_SHA; fi)" >> $GITHUB_OUTPUT
24-
env:
25-
TARGET_SHA: ${{ github.event.inputs.targetSha }}
26-
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Print the target SHA and hermes version
35+
run: |
36+
echo "targetSha=${{ github.sha }}"
37+
echo "hermes-version=${{ inputs.hermes-version }}"
2738
- name: Create tag
39+
if: ${{ inputs.release-type == 'release' }}
2840
uses: actions/github-script@v5
2941
with:
3042
script: |
3143
github.rest.git.createRef({
3244
owner: context.repo.owner,
3345
repo: context.repo.repo,
34-
ref: 'refs/tags/hermes-${{ steps.date.outputs.date }}-RNv${{ github.event.inputs.rnVersion }}-${{ steps.targetSha.outputs.targetSha }}',
35-
sha: '${{ steps.targetSha.outputs.targetSha }}'
46+
ref: 'refs/tags/hermes-v${{ inputs.hermes-version }}',
47+
sha: '${{ github.sha }}',
3648
})

.github/workflows/rn-build-hermes.yml

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,45 @@ jobs:
3131
echo "Setting release type to dry-run"
3232
echo "RELEASE_TYPE=dry-run" >> $GITHUB_OUTPUT
3333
fi
34-
build_hermesc_apple:
35-
uses: ./.github/workflows/build-hermesc-apple.yml
36-
build_apple_slices_hermes:
37-
uses: ./.github/workflows/build-apple-slices-hermes.yml
38-
needs: build_hermesc_apple
39-
build_hermes_macos:
40-
uses: ./.github/workflows/build-hermes-macos.yml
41-
needs: build_apple_slices_hermes
42-
build_hermesc_linux:
43-
uses: ./.github/workflows/build-hermesc-linux.yml
44-
# TODO: Reenable once support for MSVC is added T242502301
45-
# build_hermesc_windows:
46-
# uses: ./.github/workflows/build-hermesc-windows.yml
47-
build_android:
48-
uses: ./.github/workflows/build-android.yml
34+
- id: generate_version
35+
run: |
36+
pwd
37+
VERSION=$(node ./utils/scripts/hermes/get-hermes-version.js --build-type ${{ steps.set_release_type.outputs.RELEASE_TYPE }})
38+
echo "Generated version: $VERSION"
39+
echo "HERMES_VERSION=$VERSION" >> $GITHUB_OUTPUT
40+
# build_hermesc_apple:
41+
# uses: ./.github/workflows/build-hermesc-apple.yml
42+
# build_apple_slices_hermes:
43+
# uses: ./.github/workflows/build-apple-slices-hermes.yml
44+
# needs: build_hermesc_apple
45+
# build_hermes_macos:
46+
# uses: ./.github/workflows/build-hermes-macos.yml
47+
# needs: build_apple_slices_hermes
48+
# build_hermesc_linux:
49+
# uses: ./.github/workflows/build-hermesc-linux.yml
50+
# # TODO: Reenable once support for MSVC is added T242502301
51+
# # build_hermesc_windows:
52+
# # uses: ./.github/workflows/build-hermesc-windows.yml
53+
# build_android:
54+
# uses: ./.github/workflows/build-android.yml
55+
# needs: set_release_type
56+
# secrets: inherit
57+
# with:
58+
# release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
59+
# publish:
60+
# uses: ./.github/workflows/publish.yml
61+
# secrets: inherit
62+
# needs:
63+
# [
64+
# set_release_type,
65+
# build_hermes_macos,
66+
# build_hermesc_linux,
67+
# ]
68+
# with:
69+
# release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
70+
create-tag:
71+
uses: ./.github/workflows/create-tag.yml
4972
needs: set_release_type
50-
secrets: inherit
51-
with:
52-
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
53-
publish:
54-
uses: ./.github/workflows/publish.yml
55-
secrets: inherit
56-
needs:
57-
[
58-
set_release_type,
59-
build_hermes_macos,
60-
build_hermesc_linux,
61-
]
6273
with:
6374
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
75+
hermes-version: ${{ needs.set_release_type.outputs.HERMES_VERSION }}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
*/
10+
11+
/*::
12+
import type {BuildType} from './version-utils';
13+
*/
14+
15+
const {getVersion, validateBuildType} = require('./version-utils');
16+
const {parseArgs} = require('util');
17+
18+
const config = {
19+
options: {
20+
'build-type': {
21+
type: 'string',
22+
short: 'b',
23+
},
24+
help: {type: 'boolean'},
25+
},
26+
};
27+
28+
async function main() {
29+
const {
30+
values: {'build-type': buildType, help},
31+
/* $FlowFixMe[incompatible-call] Natural Inference rollout. See
32+
* https://fburl.com/workplace/6291gfvu */
33+
} = parseArgs(config);
34+
35+
if (help) {
36+
console.log(`
37+
Usage: node ./utils/scripts/hermes/get-hermes-version.js [OPTIONS]
38+
39+
Generates and outputs version string for the given build type.
40+
41+
Options:
42+
--build-type One of ['dry-run', 'release'].
43+
`);
44+
return;
45+
}
46+
47+
if (!validateBuildType(buildType)) {
48+
throw new Error(`Unsupported build type: ${buildType}`);
49+
}
50+
51+
const version = await getVersion(buildType);
52+
console.log(version);
53+
}
54+
55+
if (require.main === module) {
56+
void main();
57+
}

0 commit comments

Comments
 (0)