-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (43 loc) · 1.49 KB
/
crates.yml
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
name: Crates Release
on:
workflow_dispatch:
inputs:
version:
description: "major/minor/patch or semver"
required: true
default: "patch"
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo
- name: Set git credentials
run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Install cargo edit
run: cargo install cargo-edit
- name: Set version semver
if: ${{ contains(github.event.inputs.version, '.') }}
run:
echo "newVersion=$( cargo set-version ${{ github.event.inputs.version }} | awk '{print $NF}' )" >> $GITHUB_ENV
- name: Set version bump
if: ${{ !contains(github.event.inputs.version, '.') }}
run:
echo "newVersion=$( cargo set-version --bump ${{ github.event.inputs.version }} | awk '{print $NF}' )" >> $GITHUB_ENV
- name: Publish on crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --allow-dirty
- name: Push updated Cargo.toml
run: |
git tag "v${{ env.newVersion }}"
git add .
git commit -m "Release: ${{ env.newVersion }}"
git push --tags origin main