Skip to content

Commit

Permalink
Add publish workflow
Browse files Browse the repository at this point in the history
This change adds a new workflow that we can use for publishing a new
version of the crate. The workflow has to manually be invoked and will
then perform the publishing from a more or less well-defined CI
environment, after ensuring that a full CI run succeeded.
  • Loading branch information
d-e-s-o committed Nov 21, 2023
1 parent 9ee5184 commit bdc64bb
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Copyright (C) 2023 Daniel Mueller <[email protected]>
# SPDX-License-Identifier: GPL-3.0-or-later

name: Publish

on:
workflow_dispatch:

jobs:
version:
name: Retrieve version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: version
shell: bash
run: |
cargo generate-lockfile
pkgid="$(cargo pkgid)"
# Format is typically
# file://<path>/<crate>#<version>
# but could also be along the lines of
# file://<path>/<crate>#<actual-crate-name>@<version>
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, version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Dry-run package creation
run: cargo package --no-verify
- name: Create git tag
env:
version: ${{ needs.version.outputs.version }}
run: |
curl --location \
--fail-with-body \
--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 }}
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ name: Test
on:
pull_request:
push:
workflow_call:

env:
CARGO_TERM_COLOR: always
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Unreleased
----------
- Introduced `vendored-openssl` feature to build with vendored `openssl`
library
- Added GitHub Actions workflow for publishing the crate
- Bumped `apca` dependency to `0.27.0`


Expand Down

0 comments on commit bdc64bb

Please sign in to comment.