2022-09-22 13:56:27 +00:00
|
|
|
name: Nightly release
|
|
|
|
|
2023-12-05 11:52:09 +00:00
|
|
|
run-name: "Nightly release '${{ inputs.git-ref || github.ref_name }}' (publish: ${{ inputs.publish || github.event_name == 'schedule' }})"
|
|
|
|
|
2022-09-22 13:56:27 +00:00
|
|
|
on:
|
2023-03-31 18:58:42 +00:00
|
|
|
workflow_dispatch:
|
2023-12-05 11:52:09 +00:00
|
|
|
inputs:
|
|
|
|
git-ref:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
description: "The github ref of this nightly version (i.e. main, 1234567)"
|
|
|
|
default: main
|
|
|
|
publish:
|
|
|
|
required: false
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
description: "Publish the nightly release"
|
2022-09-22 13:56:27 +00:00
|
|
|
schedule:
|
|
|
|
- cron: '0 0 * * *'
|
|
|
|
|
2023-03-30 20:14:06 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
2022-09-22 13:56:27 +00:00
|
|
|
jobs:
|
2023-12-05 11:52:09 +00:00
|
|
|
release:
|
|
|
|
name: Prepare nightly release
|
|
|
|
uses: ./.github/workflows/reusable_publish_version.yml
|
|
|
|
with:
|
|
|
|
name: nightly
|
|
|
|
git-ref: ${{ inputs.git-ref || github.ref_name }}
|
|
|
|
publish: ${{ inputs.publish || github.event_name == 'schedule' }}
|
|
|
|
secrets: inherit
|
2022-09-22 13:56:27 +00:00
|
|
|
|
2023-11-19 23:53:52 +00:00
|
|
|
crate:
|
|
|
|
name: Publish surrealdb-nightly to crates.io
|
2023-12-05 11:52:09 +00:00
|
|
|
environment: crate-nightly
|
2023-11-19 23:53:52 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Install stable toolchain
|
|
|
|
uses: dtolnay/rust-toolchain@stable
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
|
|
|
|
- name: Checkout sources
|
|
|
|
uses: actions/checkout@v4
|
2023-12-05 11:52:09 +00:00
|
|
|
with:
|
|
|
|
ref: ${{ inputs.git-ref || github.ref_name }}
|
2023-11-19 23:53:52 +00:00
|
|
|
|
2023-12-06 14:46:23 +00:00
|
|
|
- name: Install release-plz
|
|
|
|
run: cargo install --force --locked --version 0.3.30 release-plz
|
|
|
|
|
|
|
|
- name: Prepare nightly crate
|
2023-11-19 23:53:52 +00:00
|
|
|
run: |
|
2023-11-21 13:24:59 +00:00
|
|
|
# Replace the crate name
|
|
|
|
# We are just going to replace the first occurance of surrealdb
|
|
|
|
sed -i "0,/surrealdb/s//surrealdb-nightly/" lib/Cargo.toml
|
2023-11-19 23:53:52 +00:00
|
|
|
|
|
|
|
# Get the date and time of the last commit
|
|
|
|
date=$(git show --no-patch --format=%ad --date=format:%Y%m%d)
|
|
|
|
time=$(git show --no-patch --format=%ad --date=format:%H%M%S)
|
|
|
|
|
|
|
|
# Update the version to a nightly one
|
2023-11-21 13:24:59 +00:00
|
|
|
# This sets the nightly version to something like `1.20231117.1130416`
|
|
|
|
# The 1 at the beginning of the patch number is just so it never starts with zero
|
|
|
|
sed -i "s#^version = \"\([[:digit:]]*\)\..*\"#version = \"\1.${date}.1${time}\"#" lib/Cargo.toml
|
2023-11-19 23:53:52 +00:00
|
|
|
|
|
|
|
# Get the short commit
|
|
|
|
shortRev=$(git rev-parse --short HEAD)
|
|
|
|
|
|
|
|
# Update the description
|
|
|
|
sed -i "s#^description = \".*\"#description = \"A nightly release of the surrealdb crate based on commit ${shortRev}\"#" lib/Cargo.toml
|
|
|
|
|
|
|
|
# Commit changes
|
|
|
|
# We are not going to push these changes. We do this because
|
|
|
|
# some git commands `release-plz` runs do not work in detached state.
|
|
|
|
git config --local user.email "actions@users.noreply.github.com"
|
|
|
|
git config --local user.name "github-actions[bot]"
|
|
|
|
git commit -am 'Prepare nightly release'
|
|
|
|
git checkout -b nightly
|
|
|
|
|
2023-12-06 14:46:23 +00:00
|
|
|
- name: Perfom release checks
|
|
|
|
if: ${{ !(inputs.publish || github.event_name == 'schedule') }}
|
|
|
|
env:
|
|
|
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
|
|
|
run: /home/runner/.cargo/bin/release-plz release --dry-run --config .config/release-plz.toml
|
2023-11-19 23:53:52 +00:00
|
|
|
|
2023-12-06 14:46:23 +00:00
|
|
|
- name: Publish the crate
|
|
|
|
if: ${{ inputs.publish || github.event_name == 'schedule' }}
|
|
|
|
env:
|
|
|
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
|
|
|
run: /home/runner/.cargo/bin/release-plz release --config .config/release-plz.toml
|