Skip to content

Commit 7317e0f

Browse files
committed
Merge branch 'workflow/release-upgradeable'
2 parents 1eadb10 + 2a1c262 commit 7317e0f

File tree

3 files changed

+123
-2
lines changed

3 files changed

+123
-2
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Release Upgradeable
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
env:
7+
UPGRADEABLE_REPO: OpenZeppelin/openzeppelin-contracts-upgradeable
8+
9+
jobs:
10+
state:
11+
name: Check state
12+
permissions:
13+
pull-requests: read
14+
if: ${{ github.repository == 'OpenZeppelin/openzeppelin-contracts' }}
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
with:
19+
repository: ${{ env.UPGRADEABLE_REPO }}
20+
ref: ${{ github.ref }}
21+
- uses: actions/checkout@v6
22+
with:
23+
ref: ${{ github.ref }}
24+
path: lib/openzeppelin-contracts
25+
- name: Set up environment
26+
uses: ./.github/actions/setup
27+
- name: Get reference commit
28+
id: get-reference-commit
29+
run: |
30+
cd lib/openzeppelin-contracts
31+
echo "commit=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
32+
- name: Check upgradeable
33+
id: check-upgradeable
34+
run: bash lib/openzeppelin/scripts/release/workflow/check-upgradeable.sh # TODO: remove path prefix when this is merged and the change are transpiled
35+
env:
36+
REFERENCE_COMMIT: ${{ steps.get-reference-commit.outputs.commit }}
37+
outputs:
38+
publish: ${{ steps.check-upgradeable.outcome }}
39+
is_prerelease: ${{ steps.check-upgradeable.outputs.is_prerelease }}
40+
41+
# copied from release-cycle.yml
42+
publish:
43+
needs: state
44+
name: Publish to npm
45+
environment: npm
46+
permissions:
47+
contents: write
48+
id-token: write
49+
if: needs.state.outputs.publish == 'success' # Note: changed from 'true' to 'success' to support the way publish is computed
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v6
53+
with:
54+
repository: ${{ env.UPGRADEABLE_REPO }}
55+
ref: ${{ github.ref }}
56+
- uses: actions/checkout@v6
57+
with:
58+
ref: ${{ github.ref }}
59+
path: lib/openzeppelin-contracts
60+
- name: Set up environment
61+
uses: ./.github/actions/setup
62+
- id: pack
63+
name: Pack
64+
run: bash scripts/release/workflow/pack.sh
65+
env:
66+
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
67+
- name: Upload tarball artifact
68+
uses: actions/upload-artifact@v5
69+
with:
70+
name: ${{ github.ref_name }}
71+
path: ${{ steps.pack.outputs.tarball }}
72+
- name: Publish
73+
run: bash scripts/release/workflow/publish.sh
74+
env:
75+
TARBALL: ${{ steps.pack.outputs.tarball }}
76+
TAG: ${{ steps.pack.outputs.tag }}
77+
- name: Create Github Release
78+
uses: actions/github-script@v8
79+
env:
80+
PRERELEASE: ${{ needs.state.outputs.is_prerelease }}
81+
with:
82+
github-token: ${{ secrets.GH_TOKEN_UPGRADEABLE }}
83+
script: await require('./lib/openzeppelin-contracts/scripts/release/workflow/github-release.js')({ github, context }, '${{ env.UPGRADEABLE_REPO }}') # TODO: remove path prefix when this is merged and the change are transpiled
84+
outputs:
85+
tarball_name: ${{ steps.pack.outputs.tarball_name }}
86+
87+
integrity_check:
88+
needs: publish
89+
name: Tarball Integrity Check
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v6
93+
- name: Download tarball artifact
94+
id: artifact
95+
uses: actions/download-artifact@v6
96+
with:
97+
name: ${{ github.ref_name }}
98+
- name: Check integrity
99+
run: bash scripts/release/workflow/integrity-check.sh
100+
env:
101+
TARBALL: ${{ steps.artifact.outputs.download-path }}/${{ needs.publish.outputs.tarball_name }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if ! git log -1 --pretty=%B | grep -q "Transpile ${REFERENCE_COMMIT}"; then
6+
echo "Expected 'Transpile ${REFERENCE_COMMIT}' but found '$(git log -1 --pretty=%B)'"
7+
exit 1
8+
fi
9+
10+
VERSION="$(jq -r .version contracts/package.json)"
11+
if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
12+
PRERELEASE="false"
13+
elif [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$ ]]; then
14+
PRERELEASE="true"
15+
else
16+
echo "Invalid version"
17+
exit 1
18+
fi
19+
20+
echo "is_prerelease=${PRERELEASE}" >> "$GITHUB_OUTPUT"

scripts/release/workflow/github-release.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ const { readFileSync } = require('fs');
22
const { join } = require('path');
33
const { version } = require(join(__dirname, '../../../package.json'));
44

5-
module.exports = async ({ github, context }) => {
5+
module.exports = async ({ github, context }, repo = undefined) => {
66
const changelog = readFileSync('CHANGELOG.md', 'utf8');
77

88
await github.rest.repos.createRelease({
99
owner: context.repo.owner,
10-
repo: context.repo.repo,
10+
repo: repo ?? context.repo.repo,
1111
tag_name: `v${version}`,
1212
target_commitish: context.sha,
1313
body: extractSection(changelog, version),

0 commit comments

Comments
 (0)