-
Notifications
You must be signed in to change notification settings - Fork 3
67 lines (60 loc) · 1.91 KB
/
release.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
name: release
on:
workflow_run:
workflows: [build]
branches: [main]
types:
- completed
workflow_dispatch:
branches: [main]
jobs:
tag-release:
if: ${{ github.event.workflow_run.conclusion == 'success' }} || ${{ github.event.workflow_dispatch }}
name: tag-release (ubuntu-latest)
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2
# Cargo setup
- name: Set up Cargo cache
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
# Tag the commit with the library version
- name: Create git tag
uses: salsify/action-detect-and-tag-new-version@v2
with:
version-command: scripts/get_version.sh
# Set release output variables
- name: Set output
id: vars
run: |
echo "TAG_NAME=v$(scripts/get_version.sh)" >> $GITHUB_ENV
echo "RELEASE_NAME=$(scripts/get_version.sh)" >> $GITHUB_ENV
echo "## Release notes" > NOTES.md
sed -n '/^## /{n; :a; /^## /q; p; n; ba}' CHANGELOG.md >> NOTES.md
# Create GitHub release
- name: Create release
id: create-release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.RELEASE_NAME }}
tag_name: ${{ env.TAG_NAME }}
append_body: true
body_path: ./NOTES.md
prerelease: false
- name: Remove notes
# Force to not error if it doesn't exist
run: rm --force NOTES.md
- name: Publish to crates.io
run: cargo publish --token ${CARGO_REGISTRY_TOKEN}
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}