-
Notifications
You must be signed in to change notification settings - Fork 23
54 lines (48 loc) · 1.7 KB
/
Copy pathpublish.yml
File metadata and controls
54 lines (48 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
name: Publish
on:
workflow_dispatch:
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
token: ${{ secrets.PAT }}
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/install@v0.1
with:
crate: cargo-workspaces
version: 0.2.44
- 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 "runner@gha.local"
git config --global user.name "Github Action"
cargo workspaces -v version -ay --force '*' --include-merged-tags --no-git-commit --exact minor
export VERSION=$(cd zngur; cargo pkgid | sed -E 's/.*#(.*)/\1/g')
# Commit and publish
git commit -am "Release $VERSION"
git tag "v$VERSION"
cargo workspaces -v publish --from-git --skip-published
git push --tags
git push