| 1 |
name: deploy |
| 2 |
|
| 3 |
on: |
| 4 |
push: |
| 5 |
tags: |
| 6 |
- 'v*.*.*' |
| 7 |
|
| 8 |
jobs: |
| 9 |
|
| 10 |
linux-binaries: |
| 11 |
permissions: |
| 12 |
# Grant the GITHUB_TOKEN additional permissions necessary for creating a release. |
| 13 |
# We only run this action for tags, so any code has already been reviewed by |
| 14 |
# someone with permissions to create a tag. |
| 15 |
contents: write |
| 16 |
|
| 17 |
runs-on: ubuntu-20.04 |
| 18 |
|
| 19 |
steps: |
| 20 |
- uses: actions/checkout@v3 |
| 21 |
|
| 22 |
- name: Install stable |
| 23 |
uses: dtolnay/rust-toolchain@stable |
| 24 |
|
| 25 |
- name: semver |
| 26 |
run: | |
| 27 |
cargo +stable install cargo-semver-checks --locked |
| 28 |
cargo semver-checks check-release |
| 29 |
|
| 30 |
- name: Build cbindgen |
| 31 |
run: | |
| 32 |
cargo +stable build --release |
| 33 |
|
| 34 |
- name: Strip cbindgen |
| 35 |
run: | |
| 36 |
strip target/release/cbindgen |
| 37 |
|
| 38 |
- name: Handle release data and files |
| 39 |
id: tagName |
| 40 |
run: | |
| 41 |
VERSION=$(cargo pkgid | cut -d# -f2 | cut -d: -f2) |
| 42 |
echo "::set-output name=version::$VERSION" |
| 43 |
# Steps to extract the last release notes from CHANGES: |
| 44 |
# 1. Remove the first three lines |
| 45 |
# 2. Stop at the next heading level |
| 46 |
# 3. Remove the last line |
| 47 |
# 4. Deindent the bullet points to avoid a markdown code block |
| 48 |
tail -n +3 CHANGES | sed '/^##/q' | |
| 49 |
sed '$ d' | awk '{$1=$1};1' > CHANGES.txt |
| 50 |
|
| 51 |
- name: Create a release |
| 52 |
run: | |
| 53 |
TAG=${{ steps.tagName.outputs.version }} |
| 54 |
gh release create ${TAG} --title "${TAG}" --notes-file "CHANGES.txt" --draft 'target/release/cbindgen#cbindgen-ubuntu20.04' |
| 55 |
env: |
| 56 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |