Skip to content

Commit bafe451

Browse files
authored
CI release management (#206)
* update release tagging and deploy * unused config * use right name, set right tag * use ref
1 parent 87e2e35 commit bafe451

12 files changed

+330
-76
lines changed

.github/workflows/benchmark-summary.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Benchmark
22
on:
33
workflow_call:
4+
inputs:
5+
git_ref:
6+
type: string
47

58
permissions:
69
# deployments permission to deploy GitHub pages website
@@ -19,7 +22,9 @@ jobs:
1922
runs-on: ubuntu-latest
2023
steps:
2124
- name: Git checkout
22-
uses: actions/checkout@v3
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ inputs.git_ref }}
2328

2429
- name: Load environment variables
2530
run: cat .github/.env >> $GITHUB_ENV
@@ -30,6 +35,7 @@ jobs:
3035
node: 18.x
3136
solana: ${{ env.SOLANA_VERSION }}
3237
cache: ${{ env.CACHE }}
38+
artifacts: program-builds-${{ inputs.git_ref }}
3339

3440
- name: Install dependencies
3541
uses: metaplex-foundation/actions/install-node-dependencies@v1

.github/workflows/benchmark.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Benchmark
22
on:
33
workflow_call:
4+
inputs:
5+
git_ref:
6+
type: string
47

58
permissions:
69
# deployments permission to deploy GitHub pages website
@@ -17,7 +20,7 @@ jobs:
1720
runs-on: ubuntu-latest
1821
steps:
1922
- name: Git checkout
20-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2124

2225
- name: Load environment variables
2326
run: cat .github/.env >> $GITHUB_ENV
@@ -28,6 +31,7 @@ jobs:
2831
node: 18.x
2932
solana: ${{ env.SOLANA_VERSION }}
3033
cache: ${{ env.CACHE }}
34+
artifacts: program-builds-${{ inputs.git_ref }}
3135

3236
- name: Install dependencies
3337
uses: metaplex-foundation/actions/install-node-dependencies@v1

.github/workflows/build-programs.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
type: string
88
solana:
99
type: string
10+
git_ref:
11+
type: string
1012
workflow_dispatch:
1113
inputs:
1214
rust:
@@ -29,7 +31,7 @@ jobs:
2931
runs-on: ubuntu-latest
3032
steps:
3133
- name: Git checkout
32-
uses: actions/checkout@v3
34+
uses: actions/checkout@v4
3335

3436
- name: Load environment variables
3537
run: cat .github/.env >> $GITHUB_ENV
@@ -59,7 +61,7 @@ jobs:
5961
- name: Upload program builds
6062
uses: actions/upload-artifact@v4
6163
with:
62-
name: program-builds
64+
name: program-builds-${{ inputs.git_ref }}
6365
# First wildcard ensures exported paths are consistently under the programs folder.
6466
path: ./program*/.bin/*.so
6567
include-hidden-files: true

.github/workflows/build-rust-client.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
type: string
88
solana:
99
type: string
10+
git_ref:
11+
type: string
1012
workflow_dispatch:
1113
inputs:
1214
rust:
@@ -29,7 +31,9 @@ jobs:
2931
runs-on: ubuntu-latest
3032
steps:
3133
- name: Git checkout
32-
uses: actions/checkout@v3
34+
uses: actions/checkout@v4
35+
with:
36+
ref: ${{ inputs.git_ref }}
3337

3438
- name: Load environment variables
3539
run: cat .github/.env >> $GITHUB_ENV

.github/workflows/create-release.yml

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Create release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
program:
7+
description: Program
8+
required: true
9+
default: core
10+
type: choice
11+
options:
12+
- core
13+
bump:
14+
description: Version bump
15+
required: true
16+
default: patch
17+
type: choice
18+
options:
19+
- patch
20+
- minor
21+
- major
22+
git_ref:
23+
description: Commit hash or branch to create release
24+
required: false
25+
type: string
26+
default: main
27+
28+
29+
env:
30+
CACHE: true
31+
32+
jobs:
33+
build_programs:
34+
name: Programs
35+
uses: ./.github/workflows/build-programs.yml
36+
secrets: inherit
37+
with:
38+
git_ref: ${{ inputs.git_ref }}
39+
40+
test_js:
41+
name: JS client
42+
needs: build_programs
43+
uses: ./.github/workflows/test-js-client.yml
44+
secrets: inherit
45+
with:
46+
git_ref: ${{ inputs.git_ref }}
47+
48+
create_release:
49+
name: Create program release
50+
runs-on: ubuntu-latest
51+
needs: test_js
52+
permissions:
53+
contents: write
54+
steps:
55+
- name: Git checkout
56+
uses: actions/checkout@v4
57+
with:
58+
ref: ${{ inputs.git_ref }}
59+
- name: Bump Program Version
60+
run: |
61+
git fetch --tags --all
62+
VERSION=`git tag -l --sort -version:refname "release/${{ inputs.program }}@*" | head -n 1 | sed 's|release/${{ inputs.program }}@||'`
63+
MAJOR=`echo ${VERSION} | cut -d. -f1`
64+
MINOR=`echo ${VERSION} | cut -d. -f2`
65+
PATCH=`echo ${VERSION} | cut -d. -f3`
66+
67+
if [ "${{ inputs.bump }}" == "major" ]; then
68+
MAJOR=$((MAJOR + 1))
69+
MINOR=0
70+
PATCH=0
71+
elif [ "${{ inputs.bump }}" == "minor" ]; then
72+
MINOR=$((MINOR + 1))
73+
PATCH=0
74+
else
75+
PATCH=$((PATCH + 1))
76+
fi
77+
78+
PROGRAM_VERSION="${MAJOR}.${MINOR}.${PATCH}"
79+
80+
echo PROGRAM_VERSION="${PROGRAM_VERSION}" >> $GITHUB_ENV
81+
82+
- name: Download Program Builds
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: program-builds-${{ inputs.git_ref }}
86+
87+
- name: Identify Program
88+
run: |
89+
PROGRAM_NAME="mpl_core" >> $GITHUB_ENV
90+
91+
- name: Create Release
92+
id: create_release
93+
uses: actions/create-release@v1
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
with:
97+
tag_name: release/${{ inputs.program }}@${{ env.PROGRAM_VERSION }}
98+
release_name: ${{ inputs.program }} v${{ env.PROGRAM_VERSION }}
99+
body: |
100+
Release ${{ inputs.program }} v${{ env.PROGRAM_VERSION }}
101+
draft: false
102+
prerelease: false
103+
104+
- name: Upload Release Asset
105+
uses: actions/upload-release-asset@v1
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
with:
109+
upload_url: ${{ steps.create_release.outputs.upload_url }}
110+
asset_path: ./programs/.bin/${{ env.PROGRAM_NAME }}.so
111+
asset_name: ${{ env.PROGRAM_NAME }}.so
112+
asset_content_type: application/octet-stream
113+
114+
# - name: Update latest tag
115+
# uses: actions/github-script@v5
116+
# with:
117+
# script: |
118+
# github.rest.git.createRef({
119+
# owner: context.repo.owner,
120+
# repo: context.repo.repo,
121+
# ref: 'refs/tags/release/${{ inputs.program }}@latest',
122+
# sha: '${{ github.sha }}'
123+
# });

0 commit comments

Comments
 (0)