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

Automate release process via Changesets #3915

Merged
merged 84 commits into from Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
a105bb3
Configure changesets
ernestognw Jan 10, 2023
cbbcede
Add missing dates
ernestognw Jan 10, 2023
c159669
Solve publishing for release candidates
ernestognw Jan 11, 2023
eb128b8
Fix publishing flag
ernestognw Jan 11, 2023
04c64f4
Fix title regex
ernestognw Jan 11, 2023
d95a5a0
Moved PR back to main when there's a final release published
ernestognw Jan 11, 2023
fbedc50
Add create PR back job
ernestognw Jan 12, 2023
6b4529d
Fix typo in pr_back
ernestognw Jan 12, 2023
d37fd80
Fix read changeset state
ernestognw Jan 12, 2023
39872ac
Fix accessing preState
ernestognw Jan 12, 2023
d976108
Fix `value === undefined`
ernestognw Jan 12, 2023
f1c4226
Fix issues with creating PR back
ernestognw Jan 12, 2023
da0b18f
Publish only contracts folder
ernestognw Jan 12, 2023
4f03b6a
Make `format-changelog.js` executable
ernestognw Jan 12, 2023
d29f472
Add tags to changeset PR
ernestognw Jan 12, 2023
4535c89
Add changeset version script to version
ernestognw Jan 12, 2023
2ec03e7
Fix mismatches between release-cycle.yml versions
ernestognw Jan 12, 2023
b609812
Add extra checks
ernestognw Jan 12, 2023
084f348
Added changelogs
ernestognw Jan 13, 2023
919211a
Rebase master
ernestognw Jan 13, 2023
edf9719
Remove environment from changesets job
ernestognw Jan 13, 2023
fefdf33
Remove Release Cycle environment from `check_state`
ernestognw Jan 13, 2023
da5c20f
Add permissions to publish tag
ernestognw Jan 13, 2023
e275830
Remove `GH_TOKEN`
ernestognw Jan 13, 2023
10eeabf
Add permissions
ernestognw Jan 13, 2023
997743d
Split workflow in scripts
ernestognw Jan 14, 2023
53e09df
Remove npx
ernestognw Jan 14, 2023
138ec52
Applied suggestions
ernestognw Jan 16, 2023
16bdf8e
Improved RegExp for `format-changelog.js`
ernestognw Jan 16, 2023
0e7249a
Removed rerun dispatch
ernestognw Jan 16, 2023
465696c
Avoid writing `NPM_TOKEN` to disk
ernestognw Jan 16, 2023
f04be5f
Pack and publish in separated steps
ernestognw Jan 16, 2023
8e86049
Use correct npm tags
ernestognw Jan 16, 2023
ea07d68
Extract changelog entry for GitHub release
ernestognw Jan 16, 2023
cd8b1f2
Fix linter warnings
ernestognw Jan 16, 2023
fbbaf1e
Change `github-script` refs
ernestognw Jan 16, 2023
7def70f
Fix `.length` in state
ernestognw Jan 16, 2023
aa3d9b0
Prefer local branchs in `set-changesets-pr-title.js`
ernestognw Jan 16, 2023
c058a68
Remove origin
ernestognw Jan 16, 2023
700a86f
Fix sorting versions error
ernestognw Jan 17, 2023
c519284
Fix typo with `core.exportVariable`
ernestognw Jan 17, 2023
faa4b93
Fix state
ernestognw Jan 17, 2023
e8dc5d4
Applied review comments
ernestognw Jan 17, 2023
d83f0fc
Change `readChangesetState`
ernestognw Jan 17, 2023
5dbddaf
Added " to $() definitions
ernestognw Jan 17, 2023
7054e6d
Fix `start` script
ernestognw Jan 17, 2023
ab89a0f
Refactor publish
ernestognw Jan 17, 2023
84b70e7
Recovering `rerun` dispatch (sorry @frangio)
ernestognw Jan 17, 2023
e699362
Fix rerun script
ernestognw Jan 17, 2023
85113f0
Fix `start` script
ernestognw Jan 17, 2023
e68c1e4
Fix `rerun.js`
ernestognw Jan 17, 2023
fe1cb92
Add `actions:write` permissions to `rerun`
ernestognw Jan 17, 2023
5d5dfd3
Allow `rerun` on other branch
ernestognw Jan 17, 2023
eb1af48
Fix state
ernestognw Jan 17, 2023
4c5d93e
Add input to identify reruns
ernestognw Jan 17, 2023
1d399ea
Fix run changesets
ernestognw Jan 17, 2023
729da37
Change input to string
ernestognw Jan 17, 2023
c439333
Attempt to use boolean input
ernestognw Jan 17, 2023
f943dd1
Use `getInput` instead
ernestognw Jan 17, 2023
91f3bb0
Add `debug` to state variables
ernestognw Jan 17, 2023
19af041
Fix order of state
ernestognw Jan 17, 2023
b3ff23e
Detect bot dispatches via `triggering_actor`
ernestognw Jan 17, 2023
ca30db6
Remove inputs from `rerun.js`
ernestognw Jan 17, 2023
b25a01f
Keep publish in root
ernestognw Jan 17, 2023
8c7e481
Get tarball from `npm pack`
ernestognw Jan 17, 2023
9ec5937
Bound function vars
ernestognw Jan 17, 2023
34264c0
Fixes after testing
ernestognw Jan 17, 2023
283b931
Fix synchronize versions
ernestognw Jan 17, 2023
e61b43d
Fix version reference during publish
ernestognw Jan 17, 2023
49bffa3
Remove double `npm pack`
ernestognw Jan 17, 2023
33aa4c6
Correctly get tarball name
ernestognw Jan 17, 2023
6c96c3c
Fixes for Github Release
ernestognw Jan 17, 2023
6b97f23
Remove VERSION variable
ernestognw Jan 18, 2023
f2e051d
Recover REF in rerun
ernestognw Jan 18, 2023
06b9cc8
Make exit prerelease condition to be in `release-cycle.yml`
ernestognw Jan 18, 2023
36c6a59
Apply review suggestions
ernestognw Jan 18, 2023
d4e0025
Add `theirs` strategy to merging master back
ernestognw Jan 18, 2023
a763dc1
Remove `rc` sections for final releases
ernestognw Jan 18, 2023
90ec2ea
Update .github/workflows/release-cycle.yml
ernestognw Jan 18, 2023
fc79086
Update scripts/release/workflow/prepare-release-merge.sh
ernestognw Jan 18, 2023
f500d3e
Update scripts/release/workflow/prepare-release-merge.sh
ernestognw Jan 18, 2023
80d2a52
Update scripts/release/workflow/prepare-release-merge.sh
ernestognw Jan 18, 2023
9832ae6
Fix publishing
ernestognw Jan 18, 2023
679e930
Isolate better the NPM_TOKEN
ernestognw Jan 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-buses-drop.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`Initializable`: optimize `_disableInitializers` by using `!=` instead of `<`. ([#3787](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3787))
12 changes: 12 additions & 0 deletions .changeset/config.json
@@ -0,0 +1,12 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "OpenZeppelin/openzeppelin-contracts"
}
],
"commit": false,
"access": "public",
"baseBranch": "master"
}
5 changes: 5 additions & 0 deletions .changeset/curvy-shrimps-enjoy.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

`ReentrancyGuard`: Add a `_reentrancyGuardEntered` function to expose the guard status. ([#3714](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3714))
5 changes: 5 additions & 0 deletions .changeset/curvy-suns-sort.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`Ownable2Step`: make `acceptOwnership` public virtual to enable usecases that require overriding it. ([#3960](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3960))
5 changes: 5 additions & 0 deletions .changeset/famous-rules-burn.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

`EnumerableMap`: add a `keys()` function that returns an array containing all the keys. ([#3920](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3920))
5 changes: 5 additions & 0 deletions .changeset/funny-rockets-compete.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

Reformatted codebase with latest version of Prettier Solidity. ([#3898](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3898))
5 changes: 5 additions & 0 deletions .changeset/gold-chicken-clean.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

`Strings`: add `equal` method. ([#3774](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3774))
5 changes: 5 additions & 0 deletions .changeset/healthy-squids-stare.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`Math`: optimize `log256` rounding check. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))
5 changes: 5 additions & 0 deletions .changeset/lemon-dogs-kiss.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`ERC20Votes`: optimize by using unchecked arithmetic. ([#3748](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3748))
5 changes: 5 additions & 0 deletions .changeset/little-kiwis-ring.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`Multicall`: annotate `multicall` function as upgrade safe to not raise a flag for its delegatecall. ([#3961](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3961))
5 changes: 5 additions & 0 deletions .changeset/pretty-hornets-play.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---

`Strings`: add `toString` method for signed integers. ([#3773](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3773))
5 changes: 5 additions & 0 deletions .changeset/tame-ladybugs-sit.md
@@ -0,0 +1,5 @@
---
'openzeppelin-solidity': patch
---

`MerkleProof`: optimize by using unchecked arithmetic. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -17,4 +17,4 @@ Fixes #???? <!-- Fill in with issue number -->

- [ ] Tests
- [ ] Documentation
- [ ] Changelog entry
- [ ] Changeset entry (run `npx changeset add`)
28 changes: 0 additions & 28 deletions .github/workflows/changelog.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/changeset.yml
@@ -0,0 +1,26 @@
name: changeset

on:
pull_request:
branches:
- master
types:
- opened
- synchronize
- labeled
- unlabeled

concurrency:
group: changeset-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-changeset') }}
steps:
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- name: Check changeset
run: npx changeset status --since=${{ github.base_ref }}
177 changes: 177 additions & 0 deletions .github/workflows/release-cycle.yml
@@ -0,0 +1,177 @@
name: Release Cycle

on:
push:
branches:
- release-v*
workflow_dispatch: {}

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
state:
name: Check state
permissions:
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- id: state
name: Get state
uses: actions/github-script@v6
env:
TRIGGERING_ACTOR: ${{ github.triggering_actor }}
with:
result-encoding: string
script: await require('./scripts/release/workflow/state.js')({ github, context, core })
outputs:
# Job Flags
start: ${{ steps.state.outputs.start }}
changesets: ${{ steps.state.outputs.changesets }}
promote: ${{ steps.state.outputs.promote }}
publish: ${{ steps.state.outputs.publish }}
merge: ${{ steps.state.outputs.merge }}

# Global variables
is_prerelease: ${{ steps.state.outputs.is_prerelease }}

start:
needs: state
name: Start new release candidate
permissions:
contents: write
actions: write
if: needs.state.outputs.start == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh
- id: start
name: Create branch with release candidate
run: bash scripts/release/workflow/start.sh
- name: Re-run workflow
uses: actions/github-script@v6
env:
REF: ${{ steps.start.outputs.branch }}
with:
script: await require('./scripts/release/workflow/rerun.js')({ github, context })

promote:
needs: state
name: Promote to final release
permissions:
contents: write
actions: write
if: needs.state.outputs.promote == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh
- name: Exit prerelease state
if: needs.state.outputs.is_prerelease == 'true'
run: bash scripts/release/workflow/exit-prerelease.sh
- name: Re-run workflow
uses: actions/github-script@v6
with:
script: await require('./scripts/release/workflow/rerun.js')({ github, context })

changesets:
needs: state
name: Changesets PR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Changesets PR
name: Update PR to release

permissions:
contents: write
pull-requests: write
if: needs.state.outputs.changesets == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # To get all tags
- name: Set up environment
uses: ./.github/actions/setup
- name: Set release title
uses: actions/github-script@v6
with:
result-encoding: string
script: await require('./scripts/release/workflow/set-changesets-pr-title.js')({ core })
- name: Create PR
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
with:
version: npm run version
title: ${{ env.TITLE }}
commit: ${{ env.TITLE }}
body: | # Wait for support on this https://github.com/changesets/action/pull/250
This is an automated PR for releasing ${{ github.repository }}
Check [CHANGELOG.md](${{ github.repository }}/CHANGELOG.md)

publish:
needs: state
name: Publish to npm
environment: npm
permissions:
contents: write
if: needs.state.outputs.publish == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- id: pack
name: Pack
run: bash scripts/release/workflow/pack.sh
env:
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
- name: Tag
run: npx changeset tag
- name: Publish
run: bash scripts/release/workflow/publish.sh
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
TARBALL: ${{ steps.pack.outputs.tarball }}
TAG: ${{ steps.pack.outputs.tag }}
- name: Push tags
run: git push --tags
- name: Create Github Release
uses: actions/github-script@v6
env:
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
with:
script: await require('./scripts/release/workflow/github-release.js')({ github, context })

merge:
needs: state
name: Release PR back to master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name: Release PR back to master
name: Create PR back to master

permissions:
contents: write
pull-requests: write
if: needs.state.outputs.merge == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # All branches
- name: Set up environment
uses: ./.github/actions/setup
- run: bash scripts/git-user-config.sh
- name: Create branch to merge
run: bash scripts/release/workflow/prepare-release-merge.sh
- name: Create PR back to master
uses: actions/github-script@v6
with:
script: |
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: 'merge/${{ github.ref_name }}',
base: 'master',
title: '${{ format('Merge {0} branch', github.ref_name) }}'
});