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: Add new workflow to release the plugin #53

Merged
merged 2 commits into from
Sep 2, 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
147 changes: 147 additions & 0 deletions .github/workflows/bump-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
name: Bump and Release

on:
workflow_dispatch:
inputs:
bump:
description: 'New version'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
- rc
- beta
- alpha

env:
CARGO_TERM_COLOR: always
ANCHOR_VERSION: v0.29.0

jobs:
build-all:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4

- name: Install core deps
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: jq pkg-config build-essential libudev-dev libssl-dev
execute_install_scripts: true

- name: Install cargo-edit
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-edit
version: "0.12.3"

- name: Run version bump script
run: |
source ./scripts/ci/bump-version.sh ${{ github.event.inputs.bump }}
echo "$old_version" > OLD_VERSION

- name: Create artificats of changes from diff
run: |
git status --porcelain | sed s/^...// | tar -cvf changes.tar --files-from -
mkdir -p changes
cd changes
mv ../changes.tar .
tar -xvf changes.tar
rm changes.tar
cd -
shell: bash

- name: Upload source with bumped version
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: bumped_source
path: changes/**/*

- name: Env variables
run: |
chmod +x ./scripts/ci/solana-version.sh
echo "CI_TAG=v$(cat VERSION)" >> $GITHUB_ENV
SOLANA_VERSION="$(./scripts/ci/solana-version.sh)"
SOLANA_VERSION="${SOLANA_VERSION#=}"
echo "SOLANA_VERSION=$SOLANA_VERSION" >> "$GITHUB_ENV"

- uses: ./.github/actions/setup-solana/

- name: Install anchor
uses: baptiste0928/cargo-install@v3
with:
crate: anchor-cli
args: --git https://github.com/coral-xyz/anchor --tag ${{ env.ANCHOR_VERSION }}

- uses: Swatinem/rust-cache@v2
with:
key: tarball-${{ runner.target }}-build-${{ hashFiles('**/Cargo.lock') }}
- name: Build release tarball
run: |
chmod +x ./scripts/ci/create-tarball.sh
chmod +x ./scripts/build-all.sh
./scripts/ci/create-tarball.sh --target ${{ matrix.target }}

- name: Upload tarball
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: release_build
path: sablier-geyser-plugin-release-*


release:
needs:
- build-all
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: bumped_source

- name: Install jq
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: jq
execute_install_scripts: true

- name: Env variables
run: |
chmod +x ./scripts/ci/solana-version.sh
echo "CI_TAG=v$(cat VERSION)" >> $GITHUB_ENV
echo "OLD_VERSION=v$(cat OLD_VERSION)" >> $GITHUB_ENV
SOLANA_VERSION="$(./scripts/ci/solana-version.sh)"
SOLANA_VERSION="${SOLANA_VERSION#=}"
echo "SOLANA_VERSION=$SOLANA_VERSION" >> "$GITHUB_ENV"
chmod +x ./scripts/ci/rust-version.sh
source scripts/ci/rust-version.sh
echo "PLUGIN_RUST_VERSION=$rust_stable" >> $GITHUB_ENV

- name: Commit and tag
uses: EndBug/add-and-commit@v9
with:
message: Bump from ${{ env.OLD_VERSION }} to ${{ env.CI_TAG }}
tag: ${{ env.CI_TAG }}

- uses: actions/download-artifact@v4
with:
name: release_build

- name: Publish Github release
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
name: ${{ env.CI_TAG }}
tag_name: ${{ env.CI_TAG }}
body: |
sablier-geyser-plugin ${{ env.CI_TAG }}
solana ${{ env.SOLANA_VERSION }}
rust ${{ env.PLUGIN_RUST_VERSION }}
# this gh action ignores the working directory, and defaults to the root of the repo
files: |
sablier-geyser-plugin-release-*
2 changes: 1 addition & 1 deletion OLD_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-alpha.0
1.0.0-alpha.2
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-alpha.1
1.0.0-alpha.3