Skip to content

Commit

Permalink
add publish action workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
busticated committed Oct 15, 2023
1 parent a5610bc commit c2d3b0b
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,47 @@ on:
workflow_dispatch:

jobs:
info:
name: Harvest Commit Info
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.info.outputs.tags }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
with:
fetch-tags: true
- name: Set Info
id: info
run: ./bin/ci-set-commit-info.sh

debug:
name: Debug
needs: info
runs-on: ubuntu-latest
steps:
- name: Log Info
run: |
echo ":::: GIT REF: ${{github.ref}}"
echo ":::: GIT REF_NAME: ${{github.ref_name}}"
echo ":::: TAGS: ${{needs.info.outputs.tags}}"
- name: Test Tag Check
if: contains(needs.info.outputs.tags, '@')
run: |
echo ":::: FOUND TAGS"
test:
name: Run Tests
needs: [info, debug]
uses: ./.github/workflows/test.yaml
secrets: inherit

publish:
name: Publish Crates
needs: [info, debug, test]
if: github.ref_name == 'main' && contains(needs.info.outputs.tags, '@')
uses: ./.github/workflows/publish.yaml
secrets: inherit
with:
tags: ${{needs.info.outputs.tags}}

30 changes: 30 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish

on:
workflow_call:
inputs:
tags:
type: string
required: true
secrets:
CARGO_REGISTRY_TOKEN:
required: true

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
with:
fetch-tags: true
- name: Install Rust Toolchain (stable)
uses: dtolnay/rust-toolchain@stable
- name: Setup Project
run: cargo xtask setup
- name: Publish to Crates.io
if: contains(inputs.tags, '@')
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo xtask crate:publish

24 changes: 24 additions & 0 deletions bin/ci-set-commit-info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

echo
echo ":::: GIT Commit:"
git log -1

echo
echo ":::: GIT Tags:"
git tag --points-at HEAD

taglistStr=$(git tag --points-at HEAD)
declare -a taglist=($taglistStr)
tags=""

for tag in "${taglist[@]}"; do
tags="${tags} ${tag}"
done

echo
echo ":::: Set Action Output: Tags:"
echo "tags=$tags" >> $GITHUB_OUTPUT
echo $tags
echo

0 comments on commit c2d3b0b

Please sign in to comment.