surrealpatch/.github/workflows/nightly.yml

88 lines
3 KiB
YAML
Raw Normal View History

2022-09-22 13:56:27 +00:00
name: Nightly release
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:
workflow_dispatch:
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 * * *'
defaults:
run:
shell: bash
2022-09-22 13:56:27 +00:00
jobs:
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
crate:
name: Publish surrealdb-nightly to crates.io
needs: [release]
environment: crate-nightly
if: ${{ inputs.publish || github.event_name == 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ inputs.git-ref || github.ref_name }}
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
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
# 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
# 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
# Install release-plz
cargo install --force --locked --version 0.3.30 release-plz
# Publish cargo crate
2023-11-21 13:24:59 +00:00
/home/runner/.cargo/bin/release-plz release --config .config/release-nightly-plz.toml