Skip to content

Commit daaf675

Browse files
committed
Adjust publish workflow to create GitHub release
This change adjusts the publish workflow to create a proper GitHub release as part of publishing the crate to crates.io. As part of cutting such a release, a Git tag is created automatically as well. Having this infrastructure in place reduces the number of manual steps that have to be performed as part of the release process.
1 parent 11c7c5b commit daaf675

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

.github/workflows/publish.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,34 @@ on:
77
workflow_dispatch:
88

99
jobs:
10+
version:
11+
name: Retrieve version
12+
runs-on: ubuntu-latest
13+
outputs:
14+
version: ${{ steps.version.outputs.version }}
15+
steps:
16+
- uses: actions/checkout@v3
17+
- id: version
18+
shell: bash
19+
run: |
20+
cargo generate-lockfile
21+
pkgid="$(cargo pkgid)"
22+
# Format is typically
23+
# file://<path>/<crate>#<version>
24+
# but could also be along the lines of
25+
# file://<path>/<crate>#<actual-crate-name>@<version>
26+
version="$(echo ${pkgid} | cut -d '#' -f2 | cut -d '@' -f2 | grep -o '[^:]*$')"
27+
if [ -z "${version}" ]; then
28+
echo "Invalid version string: ${pkgid}"
29+
exit 1
30+
fi
31+
echo "Determined crate version: ${version}"
32+
echo "version=${version}" >> $GITHUB_OUTPUT
1033
test:
1134
uses: ./.github/workflows/test.yml
1235
secrets: inherit
1336
publish:
14-
needs: [test]
37+
needs: [test, version]
1538
runs-on: ubuntu-latest
1639
steps:
1740
- uses: actions/checkout@v3
@@ -21,7 +44,27 @@ jobs:
2144
profile: minimal
2245
toolchain: stable
2346
override: true
24-
- name: Publish apca
47+
- name: Dry-run package creation
48+
run: cargo package --no-verify
49+
- name: Create git tag
50+
env:
51+
version: ${{ needs.version.outputs.version }}
52+
run: |
53+
curl --location \
54+
--request POST \
55+
--url https://api.github.com/repos/${{ github.repository }}/releases \
56+
--header "Accept: application/vnd.github+json" \
57+
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
58+
--header "X-GitHub-Api-Version: 2022-11-28" \
59+
--data "{
60+
\"tag_name\":\"v${version}\",
61+
\"target_commitish\":\"${{ github.ref }}\",
62+
\"name\":\"v${version}\",
63+
\"draft\":false,
64+
\"prerelease\":false,
65+
\"generate_release_notes\":false
66+
}"
67+
- name: Publish
2568
run: cargo publish --no-verify --token "${CARGO_REGISTRY_TOKEN}"
2669
env:
2770
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Unreleased
88
- Changed various `data::v2::stream::{Bar, Quote, Trade}` member from
99
`u64` to `Num`
1010
- Switched to using new stream authentication request message format
11+
- Adjusted publish workflow to also create GitHub release and Git tag
1112

1213

1314
0.26.2

0 commit comments

Comments
 (0)