2023-03-17 20:19:01 +00:00
|
|
|
name: Continuous Deployment
|
|
|
|
|
|
|
|
on:
|
2023-08-05 14:41:07 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
schedule:
|
|
|
|
# At 00:00 on Saturday
|
|
|
|
# https://crontab.guru/#0_0_*_*_6
|
|
|
|
- cron: "0 0 * * 6"
|
2023-03-17 20:19:01 +00:00
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- "v*.*.*"
|
|
|
|
|
2023-08-05 14:41:07 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
|
2023-03-17 20:19:01 +00:00
|
|
|
jobs:
|
2023-08-05 14:41:07 +00:00
|
|
|
publish-alpha:
|
|
|
|
name: Create an alpha release
|
2023-03-17 20:19:01 +00:00
|
|
|
runs-on: ubuntu-latest
|
2023-08-12 19:48:13 +00:00
|
|
|
permissions:
|
|
|
|
contents: write
|
2023-08-05 14:41:07 +00:00
|
|
|
if: ${{ !startsWith(github.event.ref, 'refs/tags/v') }}
|
2023-03-17 20:19:01 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout the repository
|
|
|
|
uses: actions/checkout@v3
|
2023-08-05 14:41:07 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Calculate the next release
|
|
|
|
run: |
|
|
|
|
suffix="alpha"
|
|
|
|
last_tag="$(git describe --abbrev=0 --tags `git rev-list --tags --max-count=1`)"
|
|
|
|
if [[ "${last_tag}" = *"-${suffix}"* ]]; then
|
|
|
|
# increment the alpha version
|
|
|
|
# e.g. v0.22.1-alpha.12 -> v0.22.1-alpha.13
|
|
|
|
alpha="${last_tag##*-${suffix}.}"
|
|
|
|
next_alpha="$((alpha + 1))"
|
|
|
|
next_tag="${last_tag/%${alpha}/${next_alpha}}"
|
|
|
|
else
|
|
|
|
# increment the patch and start the alpha version from 0
|
|
|
|
# e.g. v0.22.0 -> v0.22.1-alpha.0
|
|
|
|
patch="${last_tag##*.}"
|
|
|
|
next_patch="$((patch + 1))"
|
|
|
|
next_tag="${last_tag/%${patch}/${next_patch}}-${suffix}.0"
|
|
|
|
fi
|
|
|
|
# update the crate version
|
|
|
|
msg="# crate version"
|
|
|
|
sed -E -i "s/^version = .* ${msg}$/version = \"${next_tag#v}\" ${msg}/" Cargo.toml
|
|
|
|
echo "NEXT_TAG=${next_tag}" >> $GITHUB_ENV
|
|
|
|
echo "Next alpha release: ${next_tag} 🐭"
|
|
|
|
|
|
|
|
- name: Publish on crates.io
|
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: publish
|
|
|
|
args: --allow-dirty --token ${{ secrets.CARGO_TOKEN }}
|
|
|
|
|
|
|
|
- name: Generate a changelog
|
|
|
|
uses: orhun/git-cliff-action@v2
|
|
|
|
with:
|
|
|
|
config: cliff.toml
|
|
|
|
args: --unreleased --tag ${{ env.NEXT_TAG }} --strip header
|
|
|
|
env:
|
|
|
|
OUTPUT: BODY.md
|
|
|
|
|
|
|
|
- name: Publish on GitHub
|
|
|
|
uses: ncipollo/release-action@v1
|
|
|
|
with:
|
|
|
|
tag: ${{ env.NEXT_TAG }}
|
|
|
|
prerelease: true
|
|
|
|
bodyFile: BODY.md
|
|
|
|
|
|
|
|
publish-stable:
|
|
|
|
name: Create a stable release
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout the repository
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Publish on crates.io
|
2023-03-17 20:19:01 +00:00
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: publish
|
|
|
|
args: --token ${{ secrets.CARGO_TOKEN }}
|