-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
120 additions
and
235 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
# 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. | ||
|
||
# See https://github.com/facebook/metro/pull/1086 regarding handling of hotfix tags | ||
|
||
# Does main contains this tag (regular release workflow) | ||
TAG_ON_MAIN=$(git branch -a --contains "$RAW_TAG_NAME" | grep -cFx ' remotes/origin/main' || true) | ||
echo "Tag is on main branch: $TAG_ON_MAIN" | ||
|
||
# Deduce the expected name of a release branch for a tag based on Metro's release branch naming convention, eg v0.1.2-alpha.3 -> 0.1.x | ||
RELEASE_BRANCH=$(echo "$RAW_TAG_NAME" | awk -F. '{print substr($1, 2) "." $2 ".x"}') | ||
|
||
# Does a release branch contains this tag (hotfix workflow) | ||
git fetch -v --depth=1 | ||
TAG_ON_RELEASE_BRANCH=$(git branch -a --contains "$RAW_TAG_NAME" | grep -cFx " remotes/origin/$RELEASE_BRANCH" || true) | ||
echo "Tag is on release branch $RELEASE_BRANCH: $TAG_ON_RELEASE_BRANCH" | ||
|
||
if [ $TAG_ON_RELEASE_BRANCH -eq $TAG_ON_MAIN ]; then | ||
echo "Could not determine whether this tag is 'latest' or a hotfix. Aborting." | ||
exit 1 | ||
fi | ||
|
||
NPM_TAG="latest" | ||
# Use a tag name like "0.123-stable" as the dist-tag for a hotfix. This *must not* be valid semver. | ||
[ "$TAG_ON_RELEASE_BRANCH" -eq 1 ] && NPM_TAG="${RELEASE_BRANCH%.x}-stable" | ||
echo "Publishing with --tag=$NPM_TAG" | ||
|
||
npm run publish --tag="$NPM_TAG" --dry-run |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: facebook/metro/build-test-and-deploy | ||
on: | ||
workflow_call: | ||
pull_request: | ||
types: [opened, synchronize] | ||
push: | ||
tags: | ||
# The job is triggered for any tag push. Tag format validation will be done | ||
# as part of the deploy job for clearer error reporting on tag formatting | ||
- '**' | ||
|
||
# head_ref is per PR, so this ensures that updating the latest PR commit | ||
# will cancel the previous run of the workflow and trigger a new one | ||
concurrency: | ||
group: "build-test-and-deploy-${{ github.head_ref }}" | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
# run-js-checks: | ||
# runs-on: ubuntu-latest | ||
# name: "Typescript, Lint, Smoke Test" | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - uses: ./.github/actions/yarn-install | ||
# - run: yarn typecheck | ||
# - run: yarn typecheck-ts | ||
# - run: yarn lint | ||
# - run: yarn test-smoke | ||
|
||
# test-with-coverage: | ||
# runs-on: ubuntu-latest | ||
# name: "Test Coverage Calculation" | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - uses: ./.github/actions/yarn-install | ||
# - run: yarn test-coverage | ||
# - run: "./.github/scripts/install_codecov.sh" | ||
# - run: "./codecov -t ${{ secrets.CODECOV_TOKEN }} -f ./coverage/coverage-final.json" | ||
|
||
# test: | ||
# strategy: | ||
# matrix: | ||
# runs-on: ['ubuntu-latest'] # 'windows-latest' | ||
# node-version-type: ['lts', 'min-supported'] | ||
# name: "Tests [${{ matrix.runs-on }} machine, ${{ matrix.node-version-type }} Node.js]" | ||
# runs-on: ${{ matrix.runs-on }} | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
# - uses: ./.github/actions/yarn-install | ||
# with: | ||
# node-version-type: ${{ matrix.node-version-type }} | ||
# - name: Run Jest Tests | ||
# run: yarn jest --ci --maxWorkers 4 --reporters=default --reporters=jest-junit --rootdir='./' | ||
|
||
validate-tag: | ||
# runs only on tag pushes | ||
if: ${{ github.ref_type == 'tag' }} | ||
runs-on: ubuntu-latest | ||
name: "Validate Tag For Deployment" | ||
steps: | ||
- uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
if (/^v\d+(\.\d+){2}(-.*)?$/.test('${{ github.ref_name }}')) { | ||
return true; | ||
} else { | ||
core.setFailed('ERROR! Wrong tag format failed the package deployment!'); | ||
} | ||
deploy: | ||
# runs only on tag pushes | ||
if: ${{ github.ref_type == 'tag' }} | ||
runs-on: ubuntu-latest | ||
name: "Deploy" | ||
# needs: [run-js-checks, test, validate-tag] | ||
needs: [validate-tag] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/yarn-install | ||
- run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | ||
- run: "./.github/scripts/publish.sh" | ||
env: | ||
RAW_TAG_NAME: ${{ github.ref_name }} | ||
- run: rm ~/.npmrc | ||
|