Publish prerelease libraries #87
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
name: Publish prerelease libraries | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
lint-packages: | |
name: Lint Lib | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
timeout-minutes: 15 | |
strategy: | |
fail-fast: false | |
matrix: | |
package-name: | |
- blueprints-integration | |
- server-core-integration | |
- shared-lib | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".node-version" | |
- name: Prepare Environment | |
run: | | |
cd packages | |
yarn install | |
yarn lerna run --scope \*\*/${{ matrix.package-name }} --include-dependencies --stream build | |
env: | |
CI: true | |
- name: Run typecheck and linter | |
run: | | |
cd packages/${{ matrix.package-name }} | |
yarn lint | |
env: | |
CI: true | |
test-packages: | |
name: Test Lib | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
strategy: | |
fail-fast: false | |
matrix: | |
package-name: | |
- blueprints-integration | |
- server-core-integration | |
- shared-lib | |
node-version: [14.x, 16.x, 18.x] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Prepare Environment | |
run: | | |
cd packages | |
yarn install | |
yarn lerna run --scope \*\*/${{ matrix.package-name }} --include-dependencies --stream build | |
env: | |
CI: true | |
- name: Run tests | |
run: | | |
cd packages/${{ matrix.package-name }} | |
yarn unit | |
env: | |
CI: true | |
prerelease-libs: | |
name: Prerelease Lib | |
runs-on: ubuntu-latest | |
timeout-minutes: 15 | |
needs: | |
- test-packages | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".node-version" | |
- name: Check release is possible | |
id: do-publish | |
run: | | |
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then | |
echo "No Token" | |
else | |
echo "Publish prerelease" | |
echo "publish=1" >> $GITHUB_OUTPUT | |
fi | |
- name: Prepare Environment | |
if: ${{ steps.do-publish.outputs.publish }} | |
run: | | |
cd packages | |
yarn install | |
env: | |
CI: true | |
- name: Bump version | |
if: ${{ steps.do-publish.outputs.publish }} | |
run: | | |
cd packages | |
COMMIT_TIMESTAMP=$(git log -1 --pretty=format:%ct HEAD) | |
COMMIT_DATE=$(date -d @$COMMIT_TIMESTAMP +%Y%m%d-%H%M%S) | |
GIT_HASH=$(git rev-parse --short HEAD) | |
PRERELEASE_TAG=nightly-$(echo "${{ github.ref_name }}" | sed -r 's/[^a-z0-9]+/-/gi') | |
git config --global user.email "info@superfly.tv" | |
git config --global user.name "superflytvab" | |
yarn set-version-and-commit prerelease --preid $PRERELEASE_TAG-$COMMIT_DATE-$GIT_HASH | |
env: | |
CI: true | |
- name: Build | |
if: ${{ steps.do-publish.outputs.publish }} | |
run: | | |
cd packages | |
yarn build | |
env: | |
CI: true | |
- name: Modify dependencies to use npm packages | |
run: node scripts/prepublish.js | |
- name: Publish to NPM | |
id: publish-npm | |
if: ${{ steps.do-publish.outputs.publish }} | |
run: | | |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | |
cd packages | |
yarn lerna publish from-package --tag-version-prefix='' --dist-tag nightly --yes --no-verify-access | |
NEW_VERSION=$(node -p "require('./lerna.json').version") | |
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
echo "**Published:** $NEW_VERSION" >> $GITHUB_STEP_SUMMARY | |
env: | |
CI: true |