Skip to content

Publish

Publish #236

Workflow file for this run

name: Publish
on:
workflow_dispatch: # We can add version input when 1.0 is released and scheduled releases are removed
schedule:
- cron: "0 0 * * 0" # midnight UTC on Sunday
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.PUBLISH_DEPLOY_KEY }}
fetch-depth: 0
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install cargo-workspaces
uses: actions-rs/[email protected]
with:
crate: cargo-workspaces
version: 0.2.44
- name: Install Node (for changelog generation)
uses: actions/setup-node@v2
with:
node-version: 16
- name: Release
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
shell: bash
run: |
# Check if we can skip releasing a new version
# (there are no changes and the job was not manually triggered)
export CHANGED=$(cargo workspaces changed --include-merged-tags --ignore-changes "**/Cargo.toml")
if [[ -z "$CHANGED" && "$GITHUB_EVENT_NAME" != "workflow_dispatch" ]]; then
# Nothing has changed, so don't publish a new version
echo "No changes detected, skipping publish."
exit 0
fi
# Update version
git config --global user.email "[email protected]"
git config --global user.name "Github Action"
cargo workspaces -v version -ay --force '*' --include-merged-tags --no-git-commit --exact patch
export VERSION=$(cargo pkgid | sed -E 's/.*#(.*)/\1/g')
# Update changelog
npm install -g [email protected]
auto-changelog --output RELEASES.md \
--starting-version v0.11.0 \
--latest-version "$VERSION" \
--merge-pattern 'Auto merge of #(\d+) - .+\n\n(.+)' \
--template releases-template.hbs
# Commit and publish
git commit -am "Release $VERSION"
git tag "v$VERSION"
cargo workspaces -v publish --from-git --skip-published
git push --tags
cargo workspaces -v version -ay --force '*' --include-merged-tags --no-git-tag --pre-id dev preminor