From daaf6759a52b2136fc7b59bf030b25dc5740de90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Sat, 17 Jun 2023 14:33:09 -0700 Subject: [PATCH] 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. --- .github/workflows/publish.yml | 47 +++++++++++++++++++++++++++++++++-- CHANGELOG.md | 1 + 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 40d92c55..43392f6e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,11 +7,34 @@ on: workflow_dispatch: jobs: + version: + name: Retrieve version + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v3 + - id: version + shell: bash + run: | + cargo generate-lockfile + pkgid="$(cargo pkgid)" + # Format is typically + # file:///# + # but could also be along the lines of + # file:///#@ + version="$(echo ${pkgid} | cut -d '#' -f2 | cut -d '@' -f2 | grep -o '[^:]*$')" + if [ -z "${version}" ]; then + echo "Invalid version string: ${pkgid}" + exit 1 + fi + echo "Determined crate version: ${version}" + echo "version=${version}" >> $GITHUB_OUTPUT test: uses: ./.github/workflows/test.yml secrets: inherit publish: - needs: [test] + needs: [test, version] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -21,7 +44,27 @@ jobs: profile: minimal toolchain: stable override: true - - name: Publish apca + - name: Dry-run package creation + run: cargo package --no-verify + - name: Create git tag + env: + version: ${{ needs.version.outputs.version }} + run: | + curl --location \ + --request POST \ + --url https://api.github.com/repos/${{ github.repository }}/releases \ + --header "Accept: application/vnd.github+json" \ + --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\ + --header "X-GitHub-Api-Version: 2022-11-28" \ + --data "{ + \"tag_name\":\"v${version}\", + \"target_commitish\":\"${{ github.ref }}\", + \"name\":\"v${version}\", + \"draft\":false, + \"prerelease\":false, + \"generate_release_notes\":false + }" + - name: Publish run: cargo publish --no-verify --token "${CARGO_REGISTRY_TOKEN}" env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 16979a68..ff27d827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Unreleased - Changed various `data::v2::stream::{Bar, Quote, Trade}` member from `u64` to `Num` - Switched to using new stream authentication request message format +- Adjusted publish workflow to also create GitHub release and Git tag 0.26.2