name: Create release
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
permissions:
contents: write
jobs:
bump-flatbuffers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: true
- name: Check for new flatbuffers tag
id: check
run: |
set -euo pipefail
git -C flatbuffers fetch --tags origin
current=$(git -C flatbuffers describe --tags --abbrev=0)
latest=$(git -C flatbuffers tag --list 'v*' --sort=version:refname | tail -n1)
echo "current=$current" >> "$GITHUB_OUTPUT"
echo "latest=$latest" >> "$GITHUB_OUTPUT"
if [ "$current" = "$latest" ]; then
echo "updated=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "updated=true" >> "$GITHUB_OUTPUT"
- name: Update submodule
if: steps.check.outputs.updated == 'true'
env:
LATEST_TAG: ${{ steps.check.outputs.latest }}
run: |
set -euo pipefail
git -C flatbuffers checkout "$LATEST_TAG"
- name: Update Cargo.toml suffix
if: steps.check.outputs.updated == 'true'
id: update
uses: ./.github/actions/update-cargo-suffix
with:
file: ${{ github.workspace }}/Cargo.toml
suffix: ${{ steps.check.outputs.latest }}
- name: Commit and push
if: steps.check.outputs.updated == 'true'
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add flatbuffers Cargo.toml
git commit -m "Bump flatbuffers to ${{ steps.check.outputs.latest }}"
git push origin HEAD:main
echo "updated=true" >> "$GITHUB_OUTPUT"
- name: Create release
if: steps.check.outputs.updated == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.update.outputs.tag }}
name: ${{ steps.update.outputs.tag }}
target_commitish: main
generate_release_notes: true
- if: steps.check.outputs.updated == 'true'
uses: dtolnay/rust-toolchain@stable
- name: cargo login
if: steps.check.outputs.updated == 'true'
run: echo ${{ secrets.CRATES_TOKEN }} | cargo login
- name: cargo publish
if: steps.check.outputs.updated == 'true'
run: cargo publish