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

CI release management #206

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/benchmark-summary.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Benchmark
on:
workflow_call:
inputs:
git_ref:
type: string

permissions:
# deployments permission to deploy GitHub pages website
Expand All @@ -19,7 +22,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref }}

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

- name: Install dependencies
uses: metaplex-foundation/actions/install-node-dependencies@v1
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Benchmark
on:
workflow_call:
inputs:
git_ref:
type: string

permissions:
# deployments permission to deploy GitHub pages website
Expand All @@ -17,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

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

- name: Install dependencies
uses: metaplex-foundation/actions/install-node-dependencies@v1
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/build-programs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
type: string
solana:
type: string
git_ref:
type: string
workflow_dispatch:
inputs:
rust:
Expand All @@ -29,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV
Expand Down Expand Up @@ -59,7 +61,7 @@ jobs:
- name: Upload program builds
uses: actions/upload-artifact@v4
with:
name: program-builds
name: program-builds-${{ inputs.git_ref }}
# First wildcard ensures exported paths are consistently under the programs folder.
path: ./program*/.bin/*.so
include-hidden-files: true
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build-rust-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
type: string
solana:
type: string
git_ref:
type: string
workflow_dispatch:
inputs:
rust:
Expand All @@ -29,7 +31,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref }}

- name: Load environment variables
run: cat .github/.env >> $GITHUB_ENV
Expand Down
123 changes: 123 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Create release

on:
workflow_dispatch:
inputs:
program:
description: Program
required: true
default: core
type: choice
options:
- core
bump:
description: Version bump
required: true
default: patch
type: choice
options:
- patch
- minor
- major
git_ref:
description: Commit hash or branch to create release
required: false
type: string
default: main


env:
CACHE: true

jobs:
build_programs:
name: Programs
uses: ./.github/workflows/build-programs.yml
secrets: inherit
with:
git_ref: ${{ inputs.git_ref }}

test_js:
name: JS client
needs: build_programs
uses: ./.github/workflows/test-js-client.yml
secrets: inherit
with:
git_ref: ${{ inputs.git_ref }}

create_release:
name: Create program release
runs-on: ubuntu-latest
needs: test_js
permissions:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.git_ref }}
- name: Bump Program Version
run: |
git fetch --tags --all
VERSION=`git tag -l --sort -version:refname "release/${{ inputs.program }}@*" | head -n 1 | sed 's|release/${{ inputs.program }}@||'`
MAJOR=`echo ${VERSION} | cut -d. -f1`
MINOR=`echo ${VERSION} | cut -d. -f2`
PATCH=`echo ${VERSION} | cut -d. -f3`

if [ "${{ inputs.bump }}" == "major" ]; then
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
elif [ "${{ inputs.bump }}" == "minor" ]; then
MINOR=$((MINOR + 1))
PATCH=0
else
PATCH=$((PATCH + 1))
fi

PROGRAM_VERSION="${MAJOR}.${MINOR}.${PATCH}"

echo PROGRAM_VERSION="${PROGRAM_VERSION}" >> $GITHUB_ENV

- name: Download Program Builds
uses: actions/download-artifact@v4
with:
name: program-builds-${{ inputs.git_ref }}

- name: Identify Program
run: |
PROGRAM_NAME="mpl_core" >> $GITHUB_ENV

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: release/${{ inputs.program }}@${{ env.PROGRAM_VERSION }}
release_name: ${{ inputs.program }} v${{ env.PROGRAM_VERSION }}
body: |
Release ${{ inputs.program }} v${{ env.PROGRAM_VERSION }}
draft: false
prerelease: false

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./programs/.bin/${{ env.PROGRAM_NAME }}.so
asset_name: ${{ env.PROGRAM_NAME }}.so
asset_content_type: application/octet-stream

# - name: Update latest tag
# uses: actions/github-script@v5
# with:
# script: |
# github.rest.git.createRef({
# owner: context.repo.owner,
# repo: context.repo.repo,
# ref: 'refs/tags/release/${{ inputs.program }}@latest',
# sha: '${{ github.sha }}'
# });
Loading
Loading