name: Release
on:
push:
tags:
- 'v*.*.*'
jobs:
publish_workspace_crates:
name: Publish workspace crate (${{ matrix.crate }})
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
crate: [celery-codegen]
steps:
- uses: actions/checkout@v3
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Log in to crates.io
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CARGO_TOKEN }}
- name: Publish ${{ matrix.crate }} to crates.io
run: |
cd ${{ matrix.crate }}
cargo publish
publish_celery_crate:
name: Publish celery crate
runs-on: ubuntu-latest
needs: [publish_workspace_crates]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
- name: Install rust stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Prepare environment
run: |
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV;
- name: Install jq and curl
run: |
sudo apt-get update
sudo apt-get install -y jq curl
- name: Log in to crates.io
uses: actions-rs/cargo@v1
with:
command: login
args: ${{ secrets.CARGO_TOKEN }}
- name: Wait for workspace crates to update on crates.io
run: |
for subcrate in 'celery-codegen' ; do
echo "Waiting for $subcrate to update on crates.io..."
for delay in 1 5 10 20 ; do
sleep $delay
subcrate_version=$(curl "https://crates.io/api/v1/crates/$subcrate" 2> /dev/null | jq -r '.crate.newest_version')
echo "Latest version pulled: $subcrate_version"
if [ "$VERSION" == "$subcrate_version" ]; then
echo "$subcrate up-to-date!"
break
else
if [ "$delay" == "20" ]; then
echo "$subcrate failed to update on crates.io"
exit 1
fi
fi
done
done
- name: Publish celery to crates.io
run: |
cargo publish
publish_github_release:
name: Publish github release
runs-on: ubuntu-latest
needs: [publish_celery_crate]
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare environment
run: |
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV;
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Generate release notes
run: |
python scripts/generate_release_notes.py > ${{ github.workspace }}-RELEASE_NOTES.md
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: ${{ github.workspace }}-RELEASE_NOTES.md
prerelease: ${{ contains(env.TAG, '-rc') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}