surrealpatch/.github/workflows/beta.yml

149 lines
4.8 KiB
YAML
Raw Normal View History

2023-12-11 13:58:43 +00:00
# Use this workflow to trigger beta releases, both initial beta.1 and subsequent beta.x releases
name: Beta release
run-name: "Beta release (publish: ${{ inputs.publish }}, bump version: ${{ inputs.bump-version }})"
on:
workflow_dispatch:
inputs:
publish:
required: false
type: boolean
default: false
description: "Publish the beta release"
bump-version:
required: false
type: boolean
default: false
description: "Bump the version of the current beta if this is not the initial one"
defaults:
run:
shell: bash
2023-12-11 13:58:43 +00:00
permissions:
contents: write
jobs:
2023-12-11 13:58:43 +00:00
checks:
name: Pre-release checks
runs-on: ubuntu-latest
2023-12-11 13:58:43 +00:00
outputs:
branch: ${{ steps.outputs.outputs.branch }}
steps:
2023-12-11 13:58:43 +00:00
- uses: actions/checkout@v4
with:
2023-12-11 13:58:43 +00:00
fetch-depth: 0
2023-12-11 13:58:43 +00:00
- name: Determine the correct branch
id: outputs
run: |
set -x
2023-12-11 13:58:43 +00:00
if git branch -r | grep -w 'releases/beta'; then
echo "branch=releases/beta" >> $GITHUB_OUTPUT
else
echo "branch=1.x" >> $GITHUB_OUTPUT
2023-12-11 13:58:43 +00:00
fi
release:
name: Prepare beta release
needs: [checks]
uses: ./.github/workflows/reusable_publish_version.yml
with:
environment: beta
git-ref: ${{ needs.checks.outputs.branch }}
bump-version: ${{ inputs.bump-version }}
2023-12-11 13:58:43 +00:00
publish: ${{ inputs.publish }}
create-release: ${{ inputs.publish }}
secrets: inherit
bump-version:
name: Bump 1.x version
if: ${{ inputs.publish }}
needs: [checks, release]
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: releases/beta
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install a TOML parser
run: |
curl -L https://github.com/tamasfe/taplo/releases/download/0.8.1/taplo-full-linux-x86_64.gz | gunzip - > taplo
chmod +x taplo
sudo mv taplo /usr/bin/taplo
- name: Get version info
id: bump
run: |
set -x
# Retrieve just released version
betaVersion=$(taplo get -f Cargo.toml "package.version")
major=$(echo $betaVersion | tr "." "\n" | sed -n 1p)
minor=$(echo $betaVersion | tr "." "\n" | sed -n 2p)
betaNum=$(echo $betaVersion | tr "." "\n" | sed -n 4p)
nightlyVersion=${major}.$(($minor + 1)).0
echo "version=${nightlyVersion}" >> $GITHUB_OUTPUT
echo "beta-num=${betaNum}" >> $GITHUB_OUTPUT
- name: Create version bump branch
if: ${{ steps.bump.outputs.beta-num == '1' }}
env:
RUSTFLAGS: "--cfg surrealdb_unstable"
run: |
set -x
# Checkout the 1.x branch
git fetch origin 1.x
git checkout 1.x
# Switch to version bump branch
git checkout -b version-bump/v${{ steps.bump.outputs.version }}
# Bump the crate version
sed -i "s#^version = \".*\"#version = \"${{ steps.bump.outputs.version }}\"#" Cargo.toml
sed -i "s#^version = \".*\"#version = \"${{ steps.bump.outputs.version }}\"#" sdk/Cargo.toml
sed -i "s#^version = \".*\"#version = \"2.0.0-${{ steps.bump.outputs.version }}\"#" core/Cargo.toml
# Update dependency versions
sed -i "s#surrealdb-core2 = { version = \".*\", default-features#surrealdb-core2 = { version = \"=2.0.0-${{ steps.bump.outputs.version }}\", default-features#" sdk/Cargo.toml
# Update Cargo.lock without updating dependency versions
cargo check --no-default-features --features storage-mem
- name: Push the branch
if: ${{ steps.bump.outputs.beta-num == '1' }}
run: |
# Configure git
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git config --add --bool push.autoSetupRemote true
# Commit changes
git commit -am "Bump version to v${{ steps.bump.outputs.version }}"
git push
- name: Create a PR
if: ${{ steps.bump.outputs.beta-num == '1' }}
id: pr
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
run: |
set -x
url=$(gh pr create --base 1.x --title "Bump version to v${{ steps.bump.outputs.version }}" --body "Update 1.x version")
echo "url=${url}" >> $GITHUB_OUTPUT
- name: Merge the PR
if: ${{ steps.bump.outputs.beta-num == '1' }}
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }} # Need the custom user token here so we can approve and merge the PR
run: |
set -x
gh pr merge ${{ steps.pr.outputs.url }} --delete-branch --admin --squash