Skip to content

Commit

Permalink
feat: Add crate registry publish workflow
Browse files Browse the repository at this point in the history
Fixes #35
  • Loading branch information
tlater-famedly committed Jan 23, 2025
1 parent 074e246 commit f59707d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/actions/rust-prepare/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ inputs:
default: "famedly"
famedly_crates_registry_index:
description: "URL of famedly registry index"
default: "ssh://git@gitlab.com:22/famedly/company/devops/crates-index.git"
default: "ssh://git@ssh.shipyard.rs/famedly/crate-index.git"
additional_packages:
description: "Additional package to install during preparation"
default: ""
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/publish-crate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish Rust crates

# When using this workflow, specify that it runs on tag creation:
#
# on:
# push:
# tags:
# # For root tags, such as v0.4.2
# - "v[0-9]+.[0-9]+.[0-9]+"
# - "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
# # For subfolder tags, such as workflow-engine-v1.18.0
# #- "[a-zA-Z-_]+v[0-9]+.[0-9]+.[0-9]+"
# #- "[a-zA-Z-_]+v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"

on:
workflow_call:
inputs:
registry_name:
description: "Name of the registry to publish to"
type: string
default: "famedly"
registry_index:
description: "URL of the registry index"
type: string
default: "ssh://[email protected]/famedly/crate-index.git"
packages:
description: "List of packages to publish; space-separated list"
type: string
features:
description: "List of features to publish; space-separated list"
type: string
secrets:
registry-auth-token:
description: "Auth token for the registry to publish to"
required: true

jobs:
publish:
runs-on: ubuntu-latest
container: docker-oss.nexus.famedly.de/rust-container:nightly
steps:
- uses: actions/checkout@v4
- uses: famedly/backend-build-workflows/.github/actions/rust-prepare@main
with:
famedly_crates_registry_index: ${{ inputs.registry_index }}
- name: Install registry token
# Uses `echo` (bash built-in) to prevent leaking the token
# through CLI args in /proc
run: |
echo '[registries.${{ inputs.registry_name }}]' > "${CARGO_HOME}/credentials.toml"
echo '${{ secrets.registry-auth-token }}' >> "${CARGO_HOME}/credentials.toml"
- name: Publish
run: |
cargo publish --registry famedly \
${{ inputs.packages != null && format('--package {0}', inputs.packages) || '' }} \
${{ inputs.features != null && format('--features {0}', inputs.features) || '' }}
4 changes: 4 additions & 0 deletions .github/workflows/rust-workflow-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ jobs:
check:
uses: ./.github/workflows/rust-workflow.yml
secrets: inherit
publish:
uses: ./.github/workflows/publish-crate.yml
secrets:
registry-auth-token: "test-token"

0 comments on commit f59707d

Please sign in to comment.