name: "Release"
permissions:
contents: "write"
on:
workflow_run:
workflows: ["Tag"]
types:
- "completed"
jobs:
get-tag:
name: "Get Tag From Package Version"
runs-on: "ubuntu-latest"
outputs:
pkg-version: ${{ steps.pkg-version.outputs.PKG_VERSION }}
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: '0'
- name: "Get tag"
id: "pkg-version"
shell: "bash"
run: |
echo PKG_VERSION=$(awk -F ' = ' '$1 ~ /^version$/ { gsub(/["]/, "", $2); printf("%s",$2) }' Cargo.toml) >> $GITHUB_OUTPUT
create-release:
name: "Create release"
if: ${{ github.event.workflow_run.conclusion == 'success' }}
needs: "get-tag"
runs-on: ubuntu-latest
steps:
- name: "Check out the repo"
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: "Create release"
uses: taiki-e/create-gh-release-action@v1
with:
branch: "main"
ref: refs/tags/v${{ needs.get-tag.outputs.pkg-version }}
token: ${{ secrets.GITHUB_TOKEN }}
release:
name: Release
environment: Runner
if: ${{ github.event.workflow_run.conclusion == 'success' }}
needs:
- "get-tag"
- "create-release"
runs-on: ubuntu-latest
steps:
- name: "Checkout sources"
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: "Install stable toolchain"
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
- name: "Release to crates.io"
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: cargo publish --token ${CRATES_TOKEN}