Skip to content

Commit 0c89a8b

Browse files
ernestognwfrangio
andauthored
Automate release process via Changesets (#3915)
Co-authored-by: Francisco <fg@frang.io>
1 parent f81e5f5 commit 0c89a8b

37 files changed

+5645
-2173
lines changed

.changeset/beige-buses-drop.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': patch
3+
---
4+
5+
`Initializable`: optimize `_disableInitializers` by using `!=` instead of `<`. ([#3787](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3787))

.changeset/config.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{
6+
"repo": "OpenZeppelin/openzeppelin-contracts"
7+
}
8+
],
9+
"commit": false,
10+
"access": "public",
11+
"baseBranch": "master"
12+
}

.changeset/curvy-shrimps-enjoy.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': minor
3+
---
4+
5+
`ReentrancyGuard`: Add a `_reentrancyGuardEntered` function to expose the guard status. ([#3714](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3714))

.changeset/curvy-suns-sort.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': patch
3+
---
4+
5+
`Ownable2Step`: make `acceptOwnership` public virtual to enable usecases that require overriding it. ([#3960](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3960))

.changeset/famous-rules-burn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': minor
3+
---
4+
5+
`EnumerableMap`: add a `keys()` function that returns an array containing all the keys. ([#3920](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3920))

.changeset/funny-rockets-compete.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': patch
3+
---
4+
5+
Reformatted codebase with latest version of Prettier Solidity. ([#3898](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3898))

.changeset/gold-chicken-clean.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': minor
3+
---
4+
5+
`Strings`: add `equal` method. ([#3774](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3774))

.changeset/healthy-squids-stare.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': patch
3+
---
4+
5+
`Math`: optimize `log256` rounding check. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))

.changeset/lemon-dogs-kiss.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': patch
3+
---
4+
5+
`ERC20Votes`: optimize by using unchecked arithmetic. ([#3748](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3748))

.changeset/little-kiwis-ring.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': patch
3+
---
4+
5+
`Multicall`: annotate `multicall` function as upgrade safe to not raise a flag for its delegatecall. ([#3961](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3961))

.changeset/pretty-hornets-play.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': minor
3+
---
4+
5+
`Strings`: add `toString` method for signed integers. ([#3773](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3773))

.changeset/tame-ladybugs-sit.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openzeppelin-solidity': patch
3+
---
4+
5+
`MerkleProof`: optimize by using unchecked arithmetic. ([#3745](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3745))

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Fixes #???? <!-- Fill in with issue number -->
1717

1818
- [ ] Tests
1919
- [ ] Documentation
20-
- [ ] Changelog entry
20+
- [ ] Changeset entry (run `npx changeset add`)

.github/workflows/changelog.yml

-28
This file was deleted.

.github/workflows/changeset.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: changeset
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
types:
8+
- opened
9+
- synchronize
10+
- labeled
11+
- unlabeled
12+
13+
concurrency:
14+
group: changeset-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
check:
19+
runs-on: ubuntu-latest
20+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-changeset') }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Set up environment
24+
uses: ./.github/actions/setup
25+
- name: Check changeset
26+
run: npx changeset status --since=${{ github.base_ref }}

.github/workflows/release-cycle.yml

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: Release Cycle
2+
3+
on:
4+
push:
5+
branches:
6+
- release-v*
7+
workflow_dispatch: {}
8+
9+
concurrency: ${{ github.workflow }}-${{ github.ref }}
10+
11+
jobs:
12+
state:
13+
name: Check state
14+
permissions:
15+
pull-requests: read
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up environment
20+
uses: ./.github/actions/setup
21+
- id: state
22+
name: Get state
23+
uses: actions/github-script@v6
24+
env:
25+
TRIGGERING_ACTOR: ${{ github.triggering_actor }}
26+
with:
27+
result-encoding: string
28+
script: await require('./scripts/release/workflow/state.js')({ github, context, core })
29+
outputs:
30+
# Job Flags
31+
start: ${{ steps.state.outputs.start }}
32+
changesets: ${{ steps.state.outputs.changesets }}
33+
promote: ${{ steps.state.outputs.promote }}
34+
publish: ${{ steps.state.outputs.publish }}
35+
merge: ${{ steps.state.outputs.merge }}
36+
37+
# Global variables
38+
is_prerelease: ${{ steps.state.outputs.is_prerelease }}
39+
40+
start:
41+
needs: state
42+
name: Start new release candidate
43+
permissions:
44+
contents: write
45+
actions: write
46+
if: needs.state.outputs.start == 'true'
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v3
50+
- name: Set up environment
51+
uses: ./.github/actions/setup
52+
- run: bash scripts/git-user-config.sh
53+
- id: start
54+
name: Create branch with release candidate
55+
run: bash scripts/release/workflow/start.sh
56+
- name: Re-run workflow
57+
uses: actions/github-script@v6
58+
env:
59+
REF: ${{ steps.start.outputs.branch }}
60+
with:
61+
script: await require('./scripts/release/workflow/rerun.js')({ github, context })
62+
63+
promote:
64+
needs: state
65+
name: Promote to final release
66+
permissions:
67+
contents: write
68+
actions: write
69+
if: needs.state.outputs.promote == 'true'
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v3
73+
- name: Set up environment
74+
uses: ./.github/actions/setup
75+
- run: bash scripts/git-user-config.sh
76+
- name: Exit prerelease state
77+
if: needs.state.outputs.is_prerelease == 'true'
78+
run: bash scripts/release/workflow/exit-prerelease.sh
79+
- name: Re-run workflow
80+
uses: actions/github-script@v6
81+
with:
82+
script: await require('./scripts/release/workflow/rerun.js')({ github, context })
83+
84+
changesets:
85+
needs: state
86+
name: Changesets PR
87+
permissions:
88+
contents: write
89+
pull-requests: write
90+
if: needs.state.outputs.changesets == 'true'
91+
runs-on: ubuntu-latest
92+
steps:
93+
- uses: actions/checkout@v3
94+
with:
95+
fetch-depth: 0 # To get all tags
96+
- name: Set up environment
97+
uses: ./.github/actions/setup
98+
- name: Set release title
99+
uses: actions/github-script@v6
100+
with:
101+
result-encoding: string
102+
script: await require('./scripts/release/workflow/set-changesets-pr-title.js')({ core })
103+
- name: Create PR
104+
uses: changesets/action@v1
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
108+
with:
109+
version: npm run version
110+
title: ${{ env.TITLE }}
111+
commit: ${{ env.TITLE }}
112+
body: | # Wait for support on this https://github.com/changesets/action/pull/250
113+
This is an automated PR for releasing ${{ github.repository }}
114+
Check [CHANGELOG.md](${{ github.repository }}/CHANGELOG.md)
115+
116+
publish:
117+
needs: state
118+
name: Publish to npm
119+
environment: npm
120+
permissions:
121+
contents: write
122+
if: needs.state.outputs.publish == 'true'
123+
runs-on: ubuntu-latest
124+
steps:
125+
- uses: actions/checkout@v3
126+
- name: Set up environment
127+
uses: ./.github/actions/setup
128+
- id: pack
129+
name: Pack
130+
run: bash scripts/release/workflow/pack.sh
131+
env:
132+
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
133+
- name: Tag
134+
run: npx changeset tag
135+
- name: Publish
136+
run: bash scripts/release/workflow/publish.sh
137+
env:
138+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
139+
TARBALL: ${{ steps.pack.outputs.tarball }}
140+
TAG: ${{ steps.pack.outputs.tag }}
141+
- name: Push tags
142+
run: git push --tags
143+
- name: Create Github Release
144+
uses: actions/github-script@v6
145+
env:
146+
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
147+
with:
148+
script: await require('./scripts/release/workflow/github-release.js')({ github, context })
149+
150+
merge:
151+
needs: state
152+
name: Release PR back to master
153+
permissions:
154+
contents: write
155+
pull-requests: write
156+
if: needs.state.outputs.merge == 'true'
157+
runs-on: ubuntu-latest
158+
steps:
159+
- uses: actions/checkout@v3
160+
with:
161+
fetch-depth: 0 # All branches
162+
- name: Set up environment
163+
uses: ./.github/actions/setup
164+
- run: bash scripts/git-user-config.sh
165+
- name: Create branch to merge
166+
run: bash scripts/release/workflow/prepare-release-merge.sh
167+
- name: Create PR back to master
168+
uses: actions/github-script@v6
169+
with:
170+
script: |
171+
await github.rest.pulls.create({
172+
owner: context.repo.owner,
173+
repo: context.repo.repo,
174+
head: 'merge/${{ github.ref_name }}',
175+
base: 'master',
176+
title: '${{ format('Merge {0} branch', github.ref_name) }}'
177+
});

0 commit comments

Comments
 (0)