-
Notifications
You must be signed in to change notification settings - Fork 133
build: Automated release process #297
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
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
f4e8d78
test workflow
jooohhn a1f6cd1
fix macOS
jooohhn 70bf41e
npx semantic-release-cli setup
jooohhn 7d23929
release workflow
jooohhn b25ead8
change test.yml name
jooohhn c379cec
adjust for fork
jooohhn 8e129de
fix release.config.js
jooohhn e1dd717
add make test to release.yml
jooohhn c456441
disable fail-fast
jooohhn 48e3c44
disable macOS tests
jooohhn 1d500da
fix semantic-release config commonjs
jooohhn 908f3e5
chore(release-pipeline): add husky/commitizen precommit hook
jooohhn 4eacdb9
chore(build-pipeline): add commitlint
jooohhn 9493b22
test: disable flaky snippet tests
jooohhn c4f64c2
remove commit message check for PR bot
jooohhn 82daca8
build: add scripts/deployjs.py
jooohhn 80e87ab
build: update deployjs to boto3
jooohhn bba5de3
build: deployjs.py -> deploy_s3.py
jooohhn 1c6ed8d
ci: add semantic-release to release.yml
jooohhn 60c319c
chore: add notice not to edit
jooohhn 4bfafe6
docs: update CONTRIBUTING.md
jooohhn f02abab
docs: Add PR template
jooohhn 15f057f
ci: re-enable tests in release.yml
jooohhn 49eea5d
ci: remove placeholder release branch
jooohhn a37f4e6
ci: remove placeholder --dry-run
jooohhn c81c61f
Comment disabled test
jooohhn 7476c74
remove personal
jooohhn 1db12c3
ci: test workflwo dispatch
jooohhn 065454f
ci: manual release
jooohhn b9df815
Update CHANGELOG.md
jooohhn 5e54c76
ci: change branch
jooohhn bdb0177
docs: add amplitude internal
jooohhn 537c67d
docs: update contributing
jooohhn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,13 @@ | ||
| <!--- | ||
| Thanks for contributing to the Amplitude JavaScript SDK! 🎉 | ||
|
|
||
| Please fill out the following sections to help us quickly review your pull request. | ||
| ---> | ||
| ### Summary | ||
|
|
||
| <!-- What does the PR do? --> | ||
|
|
||
| ### Checklist | ||
|
|
||
| * [ ] Does your PR title have the correct [title format](../CONTRIBUTING.md#pr-commit-title-conventions) | ||
| * [ ] Does your PR have a breaking change? |
This file contains hidden or 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,19 @@ | ||
| # Validate the PR title, and ignore the commits | ||
| titleOnly: true | ||
|
|
||
| # By default types specified in commitizen/conventional-commit-types is used. | ||
| # See: https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json | ||
| # You can override the valid types | ||
|
|
||
| types: | ||
| - feat | ||
| - fix | ||
| - perf | ||
| - docs | ||
| - test | ||
| - refactor | ||
| - style | ||
| - build | ||
| - ci | ||
| - chore | ||
| - revert |
This file contains hidden or 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,77 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| dryRun: | ||
| description: 'Do a dry run instead of real release' | ||
| required: true | ||
| default: 'true' | ||
|
|
||
| jobs: | ||
| authorize: | ||
| name: Authorize | ||
| runs-on: ubuntu-18.04 | ||
| steps: | ||
| - name: ${{ github.actor }} permission check to do a release | ||
| uses: octokit/request-action@v2.0.0 | ||
| with: | ||
| route: GET /repos/:repository/collaborators/${{ github.actor }} | ||
| repository: ${{ github.repository }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| release: | ||
| name: Release | ||
| runs-on: ubuntu-18.04 | ||
| needs: [authorize] | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v1 | ||
|
|
||
| - name: Configure AWS Credentials | ||
| uses: aws-actions/configure-aws-credentials@v1 | ||
| with: | ||
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| aws-region: ${{ secrets.AWS_REGION }} | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v2 | ||
| with: | ||
| python-version: '3.8.x' | ||
| - name: Install boto3 for deployjs.python | ||
| run: pip install boto3==1.14.63 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: 10.x | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install --frozen-lockfile | ||
|
|
||
| - name: Run tests | ||
| run: make test | ||
|
|
||
| - name: Release --dry-run # Uses release.config.js | ||
| if: ${{ github.event.inputs.dryRun == 'true'}} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| AWS_REGION: ${{ secrets.AWS_REGION }} | ||
| S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} | ||
| run: npx semantic-release --dry-run | ||
|
|
||
| - name: Release # Uses release.config.js | ||
| if: ${{ github.event.inputs.dryRun == 'false'}} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
| AWS_REGION: ${{ secrets.AWS_REGION }} | ||
| S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} | ||
| run: npx semantic-release |
This file contains hidden or 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,30 @@ | ||
| name: Test | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| build: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node-version: [10.x, 12.x, 14.x] | ||
| # os: [macos-10.14, ubuntu-18.04] @TODO See if MacOS test can be fixed | ||
| os: [ubuntu-18.04] | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| steps: | ||
| - name: Check out Git repository | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Use Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v1 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
|
|
||
| - name: yarn install | ||
| run: | | ||
| yarn install --frozen-lockfile | ||
|
|
||
| - name: Build and run tests | ||
| run: | | ||
| make test |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,29 @@ | ||
| module.exports = { | ||
| "branches": ["master"], | ||
| "plugins": [ | ||
| ["@semantic-release/commit-analyzer", { | ||
| "preset": "angular", | ||
| "parserOpts": { | ||
| "noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"] | ||
| } | ||
| }], | ||
| ["@semantic-release/release-notes-generator", { | ||
| "preset": "angular", | ||
| }], | ||
| ["@semantic-release/npm", { | ||
| "npmPublish": true, | ||
| }], | ||
| ["@semantic-release/exec", { | ||
| "prepareCmd": "make release", | ||
| "publishCmd": "python scripts/deployjs.py --version ${nextRelease.version}", | ||
| "failCmd": "npm unpublish amplitude-js@${nextRelease.version}" | ||
| }], | ||
| ["@semantic-release/github", { | ||
| "assets": "amplitude*.js" | ||
| }], | ||
| ["@semantic-release/git", { | ||
| "assets": ["package.json", "src/amplitude-snippet.js"], | ||
| "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" | ||
| }], | ||
| ], | ||
| } |
This file contains hidden or 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,73 @@ | ||
| import argparse | ||
jooohhn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import os | ||
| import sys | ||
| from boto3 import Session | ||
| from botocore.exceptions import ClientError | ||
|
|
||
| unzipped_args = { | ||
| 'ContentType': 'application/javascript', | ||
| 'CacheControl': 'max-age=31536000', | ||
| 'ACL': 'public-read', | ||
| } | ||
| zipped_args = { | ||
| 'ContentType': 'application/javascript', | ||
| 'CacheControl': 'max-age=31536000', | ||
| 'ContentEncoding': 'gzip', | ||
| 'ACL': 'public-read', | ||
| } | ||
|
|
||
| def check_exists(key): | ||
| try: | ||
| key.load() | ||
| except ClientError as e: | ||
| if e.response['Error']['Code'] == '404': | ||
| return False | ||
| else: | ||
| return True | ||
|
|
||
| def upload(bucket, file, args): | ||
| bucket.upload_file( | ||
| os.path.join('dist', file), | ||
| os.path.join('libs', file), | ||
| ExtraArgs=args, | ||
| ) | ||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument('--version', '-v', required=True, | ||
| help='Version to deploy') | ||
| args = parser.parse_args() | ||
| s3 = Session( | ||
| aws_access_key_id=os.environ.get('AWS_ACCESS_KEY_ID'), | ||
| aws_secret_access_key=os.environ.get('AWS_SECRET_ACCESS_KEY'), | ||
| region_name=os.environ.get('AWS_REGION'), | ||
| ).resource('s3') | ||
| bucket = s3.Bucket(os.environ.get('S3_BUCKET_NAME')) | ||
|
|
||
| files = [ | ||
| f'amplitude-{args.version}.js', | ||
| f'amplitude-{args.version}-min.js', | ||
| f'amplitude-{args.version}.umd.js', | ||
| f'amplitude-{args.version}-min.umd.js' | ||
| ] | ||
| for file in files: | ||
| if check_exists(s3.Object(os.environ.get('S3_BUCKET_NAME'), os.path.join('libs', file))): | ||
| sys.exit(f'ERROR: {file} already exists and shouldn\'t be republished. Consider releasing a new version') | ||
| print(f'Uploading {file}') | ||
| upload(bucket, file, unzipped_args) | ||
|
|
||
| gz_files = [ | ||
| f'amplitude-{args.version}-min.gz.js', | ||
| f'amplitude-{args.version}-min.umd.gz.js' | ||
| ] | ||
| for file in gz_files: | ||
| if check_exists(s3.Object(os.environ.get('S3_BUCKET_NAME'), file)): | ||
| sys.exit(f'{file} already exists!') | ||
| print(f'Uploading {file}') | ||
| upload(bucket, file, zipped_args) | ||
|
|
||
| print(f'Success: S3 upload completed. Example: https://cdn.amplitude.com/libs/amplitude-{args.version}.js') | ||
| return 0 | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(main()) | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove this commented code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO leave it as a todo until we can fix then re-enable the flaky snippet tests