Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: alpha/beta releases #120

Merged
merged 35 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e1735e1
add parameters to release script
juliodialpad Jan 22, 2024
ab0e6a2
add comments and update logic
juliodialpad Jan 22, 2024
711d3c1
fix arguments
juliodialpad Jan 22, 2024
11d9f91
ignore errors
juliodialpad Jan 22, 2024
0cb46d5
add --verbose
juliodialpad Jan 22, 2024
12ded55
add --verbose
juliodialpad Jan 22, 2024
2bc9d4d
update scripts and docs
juliodialpad Jan 22, 2024
bc7b65b
fix logic
juliodialpad Jan 22, 2024
d589bc3
fix: increase parallel build
juliodialpad Jan 22, 2024
88465bb
test
juliodialpad Jan 22, 2024
6c19442
debugging
juliodialpad Jan 22, 2024
c0d06fd
remove debug
juliodialpad Jan 22, 2024
171c75a
push branch to avoid errors
juliodialpad Jan 22, 2024
0557397
update comment
juliodialpad Jan 22, 2024
a9ae9de
fix order
juliodialpad Jan 22, 2024
ef84641
fix: remove release command from tokens
juliodialpad Jan 22, 2024
9ec3033
remove publishConfig
juliodialpad Jan 22, 2024
0f0558e
ci: add publish-branch arg
juliodialpad Jan 22, 2024
4b44324
fix: force delete pre-release branch
juliodialpad Jan 22, 2024
4c9f966
fix: test alpha release
juliodialpad Jan 22, 2024
c721a10
chore(release): dialtone-tokens/v1.23.6-alpha.1
semantic-release-bot Jan 22, 2024
a868871
chore(release): dialtone-tokens/v1.23.6-alpha.1 gradle
semantic-release-bot Jan 22, 2024
c13fde6
chore(release): dialtone-vue2/v2.112.0-alpha.2
semantic-release-bot Jan 22, 2024
9ecfd0b
chore(release): dialtone/v9.7.0-alpha.2
semantic-release-bot Jan 22, 2024
f64a5be
fix: merge changes from release branch to feature branch
juliodialpad Jan 22, 2024
9d5c143
Merge branch 'alpha' into ci/alpha-beta-releases
juliodialpad Jan 22, 2024
7b2e4a0
Merge branch 'staging' into ci/alpha-beta-releases
juliodialpad Jan 22, 2024
4a86995
fix typo
juliodialpad Jan 23, 2024
ba08ca9
Merge branch 'staging' into ci/alpha-beta-releases
juliodialpad Jan 23, 2024
a785037
remove alpha versions
juliodialpad Jan 23, 2024
f237ccf
update release script logic
juliodialpad Jan 23, 2024
c69f262
update documentation
juliodialpad Jan 23, 2024
32c8680
remove alpha from changelog
juliodialpad Jan 23, 2024
acc72fa
minify
juliodialpad Jan 23, 2024
355c2b9
fix versions
juliodialpad Jan 23, 2024
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
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ jobs:
- name: Publish production
if: ${{ github.ref == 'refs/heads/production' }}
continue-on-error: true
run: pnpm nx run-many --target=release --parallel=false
run: pnpm nx run-many --verbose --target=release --parallel=false

- name: Publish pre-release
if: ${{ github.ref != 'refs/heads/production' }}
continue-on-error: true
run: pnpm nx run-many --target=release --args="--tag ${{ needs.get-branch-name.outputs.current_branch }}" --parallel=false
run: pnpm nx run-many --verbose --target=release --parallel=false --publish-branch ${{ needs.get-branch-name.outputs.current_branch }} --tag ${{ needs.get-branch-name.outputs.current_branch }}

- name: Set registry to GitHub packages
run: npm config set @dialpad:registry https://npm.pkg.github.com
Expand All @@ -90,17 +90,17 @@ jobs:
- name: Publish production to GitHub packages
if: ${{ github.ref == 'refs/heads/production' }}
continue-on-error: true
run: pnpm nx run-many --target=release --parallel=false
run: pnpm nx run-many --verbose --target=release --parallel=false

- name: Publish pre-release to GitHub packages
if: ${{ github.ref != 'refs/heads/production' }}
continue-on-error: true
run: pnpm nx run-many --target=release --args="--tag ${{ needs.get-branch-name.outputs.current_branch }}" --parallel=false
run: pnpm nx run-many --verbose --target=release --parallel=false --publish-branch ${{ needs.get-branch-name.outputs.current_branch }} --tag ${{ needs.get-branch-name.outputs.current_branch }}

- name: Github Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: pnpm nx run-many --target=release-github --parallel=false
run: pnpm nx run-many --verbose --target=release-github --parallel=false

android:
needs: check-dialpad-member
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build android
run: pnpm nx run dialtone-tokens:publish:android-package
run: pnpm nx run --verbose dialtone-tokens:publish:android-package

- name: Publish production - Gradle
working-directory: ./packages/dialtone-tokens
Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Build swift
run: pnpm nx run dialtone-tokens:publish:ios-package
run: pnpm nx run --verbose dialtone-tokens:publish:ios-package

- name: Publish production - Swift
uses: cpina/[email protected]
Expand Down
39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,46 @@ pnpm nx build dialtone-documentation

### Releasing

Running these commands will call [release.sh](./scripts/release.sh) which
automatically release all packages that need to be released.

Once done, a GitHub Action will be triggered, you can check the progress here:
[release.yml](https://github.com/dialpad/dialtone/actions/workflows/release.yml)

#### Production

This can only be run while on **staging** branch. After running the command, it will execute the following steps:

1. Run build on the affected projects to improve the speed of the next step.
2. Run release-local script on the affected projects to verify and increase the version according to commits.
3. Merge `staging` version changes to `production`
4. Push `production` branch.
- A GHA will publish the release on npm and GitHub with `@latest` tag.
5. Merge changes from `production` back to `staging`

```bash
pnpm run release:affected
pnpm run release
```

This will automatically release all packages that need to be released.
#### Alpha/Beta

Needs to be run while on your feature branch. After running the command, it will execute the following steps:

1. Delete local and remote `alpha/beta` branch.
2. Checkout to a clean `alpha/beta` branch and push to origin.
3. Run build on the affected projects to improve the speed of the next step.
4. Run release-local script on the affected projects to verify and increase the version according to commits.
5. Push updated `alpha/beta` branch to origin.
- A GHA will publish the release on npm and GitHub with `@alpha` or `@beta` tag.
6. Merge changes from `alpha/beta` back to your feature branch.

```bash
pnpm run release:alpha
```

```bash
pnpm run release:beta
```

## Usage

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"start:dialtone-vue3": "nx run-many --target=start --projects=dialtone-css,dialtone-vue3",
"start:dialtone-vue2": "nx run-many --target=start --projects=dialtone-css,dialtone-vue2",
"prepare": "husky install",
"release:affected": "./scripts/release.sh",
"release": "./scripts/release.sh",
"release:alpha": "./scripts/release.sh alpha",
"release:beta": "./scripts/release.sh beta",
"test:vitest": "vitest"
},
"devDependencies": {
Expand Down
34 changes: 28 additions & 6 deletions packages/dialtone-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"build:token-transformer": "pnpm run build:token-transformer:light && pnpm run build:token-transformer:dark",
"build:token-transformer:light": "token-transformer tokens token_transformer/tokens-light.json root,base/default,semantic/dp/default,components/checkbox,components/avatar/default,components/badge/default,components/checkbox/default,components/icon/default,components/radio/default root --expandTypography=true --expandShadow=true",
"build:token-transformer:dark": "token-transformer tokens token_transformer/tokens-dark.json root,base/default,base/dark,semantic/dp/default,semantic/dp/dark,components/avatar/default,components/badge/default,components/checkbox/default,components/checkbox/dark,components/icon/default,components/radio/default,components/radio/dark root --expandTypography=true --expandShadow=true",
"release": "semantic-release --no-ci --extends ./release-local.config.cjs",
"publish:external-packages": "pnpm run publish:android-package && pnpm run publish:ios-package",
"publish:android-package": "cp ./AndroidManifest.xml dist/android && ./gradlew publishToMavenLocal -Pversion=$npm_package_version",
"publish:ios-package": "./build-ios.js",
Expand All @@ -19,10 +18,6 @@
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"author": "Dialpad",
"license": "MIT",
"bugs": {
"url": "https://github.com/dialpad/dialtone-tokens/issues"
Expand All @@ -39,5 +34,32 @@
"token-transformer": "^0.0.31",
"tsx": "^4.7.0",
"typescript": "^5.1.6"
}
},
"contributors": [
{
"name": "Brad Paugh",
"email": "[email protected]",
"url": "https://github.com/braddialpad"
},
{
"name": "Francis Rupert",
"email": "[email protected]",
"url": "https://github.com/francisrupert"
},
{
"name": "Julio Ortega",
"email": "[email protected]",
"url": "https://github.com/juliodialpad"
},
{
"name": "Ignacio Ropolo",
"email": "[email protected]",
"url": "https://github.com/iropolo"
},
{
"name": "Nina Repetto",
"email": "[email protected]",
"url": "https://github.com/ninamarina"
}
]
}
49 changes: 41 additions & 8 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
#!/usr/bin/env bash
set -e

branch="$(git rev-parse --abbrev-ref HEAD)"
current_branch="$(git rev-parse --abbrev-ref HEAD)"
release_branch="${1:-production}"

if ! [[ "$branch" =~ ^staging$ ]]; then
echo "This script can only be run while on staging branch"
if [[ "$release_branch" == "production" && "$current_branch" != "staging" ]]; then
echo "Releasing production can only be done while on staging branch"
exit 1;
elif [[ "$release_branch" == "$current_branch" ]]; then
echo "Releasing $release_branch can't be done while on $current_branch branch"
echo "Make sure to checkout to your feature branch"
exit 1;
fi

if [[ "$release_branch" == "alpha" || "$release_branch" == "beta" ]]; then
echo "Deleting local and remote $release_branch branch"
git branch -D "$release_branch" || true
git push origin --delete "$release_branch" || true

echo "Checking out and pushing a clean $release_branch branch"
git checkout -b "$release_branch";
git push origin "$release_branch"
fi

git pull &&
pnpm nx affected --target=release-local --parallel=false &&
git checkout production &&
git merge --ff-only staging &&
git push -u origin production
echo "Running build in parallel to improve performance"
pnpm nx affected --verbose --target=build --parallel=6;

echo "Running release-local on affected projects"
pnpm nx affected --verbose --target=release-local --parallel=false;

if [[ "$release_branch" == "production" && "$current_branch" == "staging" ]]; then
echo "Checking out to $release_branch"
git checkout "$release_branch";

echo "Updating branch"
git pull;

echo "Merging changes"
git merge --ff-only "$current_branch";
fi

echo "Pushing changes to $release_branch"
git push -u origin "$release_branch";

echo "Merge changes back to $current_branch"
git checkout "$current_branch"
git merge --ff-only "$release_branch"
Loading