diff --git a/.github/workflows/publish-beta.yml b/.github/workflows/publish-beta.yml new file mode 100644 index 000000000..88e4addfd --- /dev/null +++ b/.github/workflows/publish-beta.yml @@ -0,0 +1,73 @@ +name: Publish beta lido-ui-v4 + +on: + workflow_dispatch: + inputs: + branch: + description: 'Branch to release beta version from' + required: true + default: 'lido-ui-v4-canary' + push: + +permissions: + contents: write + pages: write + +jobs: + deploy: + runs-on: ubuntu-latest + env: + NODE_OPTIONS: --max_old_space_size=4096 + SOURCE_BRANCH: 'release-beta-version' # ${{ github.event.inputs.branch }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ env.SOURCE_BRANCH }} + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: 'yarn' + + - name: Install Dependencies + run: yarn install --immutable + + - name: Build Components + run: yarn build + + - name: Publish Beta to NPM + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + # Run semantic-release and capture its output + RELEASE_OUTPUT=$(npx semantic-release -t '${version}-${{ github.workflow_sha }}' --dry-run) + + # Extract the version from semantic-release output + if echo "$RELEASE_OUTPUT" | grep -q "The next release version is"; then + PACKAGE_VERSION=$(echo "$RELEASE_OUTPUT" | grep "The next release version is" | sed -E 's/.*The next release version is ([0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+).*/\1/') + echo "Detected version: $PACKAGE_VERSION" + else + echo "No new version detected, using current version" + PACKAGE_VERSION=$(node -p "require('./package.json').version") + fi + + # Actually run semantic-release + npx semantic-release -t '${version}-${{ github.workflow_sha }}' + + echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV + +# # Note: You need to create a Personal Access Token with 'repo' scope +# # and add it as a repository secret named REPO_ACCESS_TOKEN +# - name: Trigger workflow in target repository +# uses: peter-evans/repository-dispatch@v2 +# with: +# token: ${{ secrets.REPO_ACCESS_TOKEN }} +# repository: ${{ github.event.inputs.target_repo }} +# event-type: beta-release +# client-payload: '{"version": "${{ env.PACKAGE_VERSION }}", "workflow": "${{ github.event.inputs.target_workflow }}"}' diff --git a/.releaserc.cjs b/.releaserc.cjs index 536779715..694655b34 100644 --- a/.releaserc.cjs +++ b/.releaserc.cjs @@ -3,6 +3,9 @@ module.exports = { { name: 'lido-ui-v4' }, { name: 'lido-ui-v4-canary', "channel": "alpha", "prerelease": "alpha" + }, + { + name: 'release-beta-version', "channel": "alpha", "prerelease": "beta" } ], plugins: [ diff --git a/README.md b/README.md index 0543d3448..e5033bab0 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,27 @@ Packages are automatically published to npm when you push to master. The publica For correct version detection, please follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/). +### Beta Releases + +You can manually trigger a beta release from any branch using the GitHub Actions workflow: + +1. Go to the "Actions" tab in the GitHub repository +2. Select the "Publish beta lido-ui-v4" workflow +3. Click "Run workflow" +4. Enter the following information: + - **Branch**: The branch to release from (e.g., `feature/new-component`) + - **Target Repository**: The repository where you want to trigger a workflow after the release (format: `owner/repo`) + - **Target Workflow**: The name of the workflow file to trigger in the target repository + +This will: +1. Create and publish a beta version to npm with a version like `4.0.0-beta.1` +2. Deploy a Storybook instance for this beta version +3. Trigger a workflow in the specified target repository, providing the released version name + +**Prerequisites**: +- You need to create a GitHub Personal Access Token with `repo` scope +- Add this token as a repository secret named `REPO_ACCESS_TOKEN` + ## Customizing CSS Variables Lido UI provides a comprehensive set of CSS variables that can be overridden to match your application's design system. This allows you to maintain the functionality of Lido UI components while adapting their appearance to your brand.