forked from surrealdb/surrealdb
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (125 loc) · 4.79 KB
/
beta.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# 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
permissions:
contents: write
jobs:
checks:
name: Pre-release checks
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.outputs.outputs.branch }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine the correct branch
id: outputs
run: |
set -x
if git branch -r | grep -w 'releases/beta'; then
echo "branch=releases/beta" >> $GITHUB_OUTPUT
else
echo "branch=1.x" >> $GITHUB_OUTPUT
fi
release:
name: Prepare beta release
needs: [checks]
uses: ./.github/reusable/publish-version.yml
with:
environment: beta
git-ref: ${{ needs.checks.outputs.branch }}
bump-version: ${{ inputs.bump-version }}
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 }}\"#" crates/sdk/Cargo.toml
sed -i "s#^version = \".*\"#version = \"2.1.0-${{ steps.bump.outputs.version }}\"#" crates/core/Cargo.toml
# Update dependency versions
sed -i "s#surrealdb-core2 = { version = \".*\", default-features#surrealdb-core2 = { version = \"=2.1.0-${{ steps.bump.outputs.version }}\", default-features#" crates/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