Skip to content

Commit

Permalink
ci: Split publish scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
sidcha committed Mar 15, 2024
1 parent 8e933e1 commit a665e55
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 35 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/publish-libosdp-sys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Copyright (c) 2024 Siddharth Chandrasekaran <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
#

name: Publish libosdp-sys

on:
workflow_dispatch:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'libosdp-sys-v*'

jobs:
cross_platform_check:
name: Build crate on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# macos-13 is an intel runner, macos-14 is apple silicon
os: [ubuntu-latest, macos-13, macos-14, windows-latest]
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- run: cargo build -p libosdp-sys

publish:
name: Publish Crate
needs: [cross_platform_check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: "Publish crate"
run: |
cargo publish --token ${CRATES_TOKEN} -p libosdp-sys
env:
CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
29 changes: 2 additions & 27 deletions .github/workflows/publish-libosdp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@ name: Publish libosdp

on:
workflow_dispatch:
inputs:
tag:
description: 'Tag'
required: true
push:
# Sequence of patterns matched against refs/tags
tags:
- 'libosdp-sys-v*'
- 'libosdp-v*'

jobs:
Expand All @@ -34,17 +29,7 @@ jobs:
with:
toolchain: stable
override: true
- name: "Setup environment - trigger"
if: github.ref == 'refs/heads/master'
run: echo "TAG=${TRIGGER_TAG}" >> "${GITHUB_ENV}"
env:
TRIGGER_TAG: ${{ github.event.inputs.tag }}
- name: "Setup environment - tag"
if: github.ref != 'refs/heads/master'
run: echo "TAG=${REL_TAG}" >> "${GITHUB_ENV}"
env:
REL_TAG: ${{ github.ref_name }}
- run: cargo build -p $(echo ${TAG} | perl -pe 's/([a-z\-]+)-v.*/\1/')
- run: cargo build -p libosdp

publish:
name: Publish Crate
Expand All @@ -58,18 +43,8 @@ jobs:
with:
toolchain: stable
override: true
- name: "Setup environment - trigger"
if: github.ref == 'refs/heads/master'
run: echo "TAG=${TRIGGER_TAG}" >> "${GITHUB_ENV}"
env:
TRIGGER_TAG: ${{ github.event.inputs.tag }}
- name: "Setup environment - tag"
if: github.ref != 'refs/heads/master'
run: echo "TAG=${REL_TAG}" >> "${GITHUB_ENV}"
env:
REL_TAG: ${{ github.ref_name }}
- name: "Publish crate"
run: |
cargo publish --token ${CRATES_TOKEN} -p $(echo ${TAG} | perl -pe 's/([a-z\-]+)-v.*/\1/')
cargo publish --token ${CRATES_TOKEN} -p libosdp
env:
CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
12 changes: 4 additions & 8 deletions .github/workflows/publish-osdpctl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,18 @@
# SPDX-License-Identifier: Apache-2.0
#

name: Publish Crate
name: Publish osdpctl

on:
workflow_dispatch:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'osdpctl-v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag'
required: true

jobs:
publish:
name: Publish Crate - osdpctl
name: Publish Crate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -41,6 +37,6 @@ jobs:
REL_TAG: ${{ github.ref_name }}
- name: "Publish crate"
run: |
cargo publish --token ${CRATES_TOKEN} -p $(echo ${TAG} | perl -pe 's/([a-z\-]+)-v.*/\1/')
cargo publish --token ${CRATES_TOKEN} -p osdpctl
env:
CRATES_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

0 comments on commit a665e55

Please sign in to comment.