Skip to content

Merge pull request #787 from Fi3/AddCloneForSv1Methods #4

Merge pull request #787 from Fi3/AddCloneForSv1Methods

Merge pull request #787 from Fi3/AddCloneForSv1Methods #4

Workflow file for this run

# This job will auto detect changes in crates and auto bump the patch versions if changes are detected, and push to
# the bot/versioning branch. Lastly, it will auto create a PR (bot/versioning -> main).
# Since cargo-smart-release does not yet support autodetection of MAJOR and MINOR changes with regards to Semver,
# any MAJOR/MINOR versioning will need to be manually changed in the package Cargo.toml.
# This workflow should not run if the push is resulting from this workflow, but this not necessarily guaranteed since the
# a developer could make a minor change to the bot/versioning PR, and the latest author would no longer be "Github Actions Bot".
# If this happens, this will run again but since there will be no updates to versions, `cargo-smart-release` will fail, and as a result,
# this workflow will fail, which is good because this ensures we do not get caught in an infinite PR loop
on:
push:
branches: [ main ]
name: publish crate updates
jobs:
autoversion:
name: Autoversion
# Dont run if the last commit is due to versioning
if: github.event.commits[0].author.name != 'github-actions[bot]' || github.event.commits[0].author.name != 'Github Actions Bot'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v3
# need this to ensure we fetch all relevant commits. The workflow will fail
# if we don't fetch all commits down to the previous HEAD before the merge
with:
fetch-depth: 0
# config "Github Actions Bot". This will help us differentiate who authored the push
# to main in line 15, so we dont make PRs after a merge from the versioning branch
- name: setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
# cargo-smart-release requires at least one object in the .git/objects database to detect changes
# so creating an empty commit will create that object
- name: Fetch
run: git commit --allow-empty -m 'empty version commit'
# install the smart release tool used to version the crates
- name: Install cargo-smart-release
run: cargo install cargo-smart-release
# only autobump versions (see https://crates.io/crates/cargo-smart-release for flags refs)
- name: Commit version updates
run: sh ./sv2-publish.sh -e -u --no-publish --no-push --no-changelog
- name: Rebase
run: git rebase origin/main
# push updates to `bot/versioning` branch. We must add `--tags` to ensure the
# version tags created by `cargo-smart-release` get moved into main on the PR merge
# We cannot create releases without the tags
- name: Push version updates to main
run: git push -f --no-verify origin --tags main:bot/versioning
# Action to create PR
- name: Create pull request
uses: peter-evans/create-pull-request@v4
with:
base: main
branch: bot/versioning