Skip to content

Commit

Permalink
new release process (#122)
Browse files Browse the repository at this point in the history
* new release process

* separate solana and svm releases

* sanitize rust client ref

* sanitize start validator
  • Loading branch information
nhanphan authored Jan 15, 2025
1 parent df5b5fe commit 89c1d6b
Show file tree
Hide file tree
Showing 12 changed files with 485 additions and 88 deletions.
19 changes: 16 additions & 3 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,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 @@ -55,11 +59,20 @@ jobs:
run: ./build.sh
env:
PROGRAMS: ${{ env.PROGRAMS }}

- name: Sanitize Ref
id: sanitize
shell: bash
run: |
REF="${{ inputs.git_ref }}"
if [ -z "$REF" ]; then
REF="default"
fi
SANITIZED=${REF//\//-}
echo "sanitized=$SANITIZED" >> "$GITHUB_OUTPUT"
- name: Upload program builds
uses: actions/upload-artifact@v4
with:
name: program-builds
name: program-builds-${{ steps.sanitize.outputs.sanitized }}
# 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
161 changes: 161 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Create release

on:
workflow_call:
inputs:
program:
description: Program
required: true
default: bubblegum
type: string
type:
description: Type of release
required: true
default: solana
type: string
bump:
description: Version bump (patch, minor, major)
required: true
default: patch
type: string
git_ref:
description: Commit hash or branch to create release
required: false
type: string

env:
CACHE: true

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

test_programs:
name: Programs
uses: ./.github/workflows/test-programs.yml
secrets: inherit
with:
program_matrix: '["${{ inputs.program }}"]'
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 }}

test_rust:
name: Rust client
needs: build_programs
uses: ./.github/workflows/test-rust-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
if [ "${{ inputs.type }}" == "solana" ]; then
TAG_NAME="release/${{ inputs.program }}"
elif [ "${{ inputs.type }}" == "svm" ]; then
TAG_NAME="release/${{ inputs.program }}-svm"
elif [ "${{ inputs.type }}" == "commit" ]; then
COMMIT_SHORTENED=`echo ${{ inputs.git_ref }} | cut -c1-7`
TAG_NAME="release/${{ inputs.program }}-${COMMIT_SHORTENED}"
else
echo "Invalid type: ${{ inputs.type }}"
exit 1
fi
VERSION=`git tag | grep '^release/${{ inputs.program }}' | sort -t@ -k2 -V | tail -n1 | cut -d@ -f2`
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
echo TAG_NAME="${TAG_NAME}" >> $GITHUB_ENV
echo COMMIT_SHORTENED="${COMMIT_SHORTENED}" >> $GITHUB_ENV
- name: Sanitize Ref
id: sanitize
shell: bash
run: |
REF="${{ inputs.git_ref }}"
if [ -z "$REF" ]; then
REF="default"
fi
SANITIZED=${REF//\//-}
echo "sanitized=$SANITIZED" >> "$GITHUB_OUTPUT"
- name: Download Program Builds
uses: actions/download-artifact@v4
with:
name: program-builds-${{ steps.sanitize.outputs.sanitized }}

- name: Identify Program
run: |
echo PROGRAM_NAME="${{ inputs.program }}" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG_NAME }}@${{ env.PROGRAM_VERSION }}
release_name: ${{ env.TAG_NAME }}@${{ env.PROGRAM_VERSION }}
body: |
Release ${{ env.TAG_NAME }}@${{ 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 }}'
# });
35 changes: 35 additions & 0 deletions .github/workflows/create-solana-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create Solana release

on:
workflow_dispatch:
inputs:
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:
create_release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Create release
uses: ./.github/workflows/create-release.yml
with:
git_ref: ${{ inputs.git_ref }}
bump: ${{ inputs.bump }}
program: bubblegum
type: solana
35 changes: 35 additions & 0 deletions .github/workflows/create-svm-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create SVM release

on:
workflow_dispatch:
inputs:
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: svm

env:
CACHE: true

jobs:
create_release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Create release
uses: ./.github/workflows/create-release.yml
with:
git_ref: ${{ inputs.git_ref }}
bump: ${{ inputs.bump }}
program: bubblegum
type: svm
4 changes: 2 additions & 2 deletions .github/workflows/deploy-js-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
contents: write
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.SVC_TOKEN }}

Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Git checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

Expand Down
Loading

0 comments on commit 89c1d6b

Please sign in to comment.