Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,47 @@ name: Publish Tag
on:
workflow_dispatch:
inputs:
rnVersion:
description: "The React Native version that will use this tag"
release-type:
required: true
targetSha:
description: "The SHA you want to tag. If not specified it will tag the HEAD of the selected branch"
required: false
description: The type of release we are building. It could be commitly, release or dry-run
type: choice
options:
- release
- commitly
- dry-run
hermes-version:
required: true
description: The Hermes version to use for this tag
type: string
workflow_call:
inputs:
release-type:
required: true
description: The type of release we are building. It could be commitly, release or dry-run
type: string
hermes-version:
required: true
description: The Hermes version to use for this tag
type: string

jobs:
publish:
runs-on: [ubuntu-latest]

steps:
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Get the target SHA
id: targetSha
run: echo "targetSha=$(if [ -z "$TARGET_SHA" ]; then echo $GITHUB_SHA; else echo $TARGET_SHA; fi)" >> $GITHUB_OUTPUT
env:
TARGET_SHA: ${{ github.event.inputs.targetSha }}

- name: Checkout
uses: actions/checkout@v4
- name: Print the target SHA and hermes version
run: |
echo "targetSha=${{ github.sha }}"
echo "hermes-version=${{ inputs.hermes-version }}"
- name: Create tag
if: ${{ inputs.release-type == 'release' }}
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/hermes-${{ steps.date.outputs.date }}-RNv${{ github.event.inputs.rnVersion }}-${{ steps.targetSha.outputs.targetSha }}',
sha: '${{ steps.targetSha.outputs.targetSha }}'
ref: 'refs/tags/hermes-v${{ inputs.hermes-version }}',
sha: '${{ github.sha }}',
})
17 changes: 17 additions & 0 deletions .github/workflows/rn-build-hermes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jobs:
EVENT_NAME: ${{ github.event_name }}
REF: ${{ github.ref }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node.js
uses: ./.github/actions/setup-node
- name: Install node dependencies
uses: ./.github/actions/yarn-install
- id: set_release_type
run: |
if [[ $EVENT_NAME == "workflow_dispatch" ]]; then
Expand All @@ -31,6 +37,11 @@ jobs:
echo "Setting release type to dry-run"
echo "RELEASE_TYPE=dry-run" >> $GITHUB_OUTPUT
fi
- id: generate_version
run: |
VERSION=$(node ./utils/scripts/hermes/get-hermes-version.js --build-type ${{ steps.set_release_type.outputs.RELEASE_TYPE }})
echo "Generated version: $VERSION"
echo "HERMES_VERSION=$VERSION" >> $GITHUB_OUTPUT
build_hermesc_apple:
uses: ./.github/workflows/build-hermesc-apple.yml
build_apple_slices_hermes:
Expand Down Expand Up @@ -61,3 +72,9 @@ jobs:
]
with:
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
create-tag:
uses: ./.github/workflows/create-tag.yml
needs: publish
with:
release-type: ${{ needs.set_release_type.outputs.RELEASE_TYPE }}
hermes-version: ${{ needs.set_release_type.outputs.HERMES_VERSION }}
57 changes: 57 additions & 0 deletions utils/scripts/hermes/get-hermes-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/

/*::
import type {BuildType} from './version-utils';
*/

const {getVersion, validateBuildType} = require('./version-utils');
const {parseArgs} = require('util');

const config = {
options: {
'build-type': {
type: 'string',
short: 'b',
},
help: {type: 'boolean'},
},
};

async function main() {
const {
values: {'build-type': buildType, help},
/* $FlowFixMe[incompatible-call] Natural Inference rollout. See
* https://fburl.com/workplace/6291gfvu */
} = parseArgs(config);

if (help) {
console.log(`
Usage: node ./utils/scripts/hermes/get-hermes-version.js [OPTIONS]

Generates and outputs version string for the given build type.

Options:
--build-type One of ['dry-run', 'release'].
`);
return;
}

if (!validateBuildType(buildType)) {
throw new Error(`Unsupported build type: ${buildType}`);
}

const version = await getVersion(buildType);
console.log(version);
}

if (require.main === module) {
void main();
}