Release on Crates and NPM #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: (main) Crates release | |
# npm publish and GitHub release are triggered by this | |
on: | |
workflow_dispatch: | |
inputs: | |
ezno-version: | |
description: "major/minor/patch or semver for Ezno (cli)" | |
required: false | |
default: "none" | |
ezno-parser-version: | |
description: "major/minor/patch or semver for parser" | |
required: false | |
default: "none" | |
ezno-checker-version: | |
description: "major/minor/patch or semver for type checker" | |
required: false | |
default: "none" | |
other-versions: | |
description: "comma seperated 'name=version_argument' pairs" | |
required: false | |
default: "none" | |
concurrency: release-crate | |
env: | |
CACHE_PATHS: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
jobs: | |
crates-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Set git credentials | |
run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
- id: set-arguments | |
run: | | |
KEY_PAIR_ARGS="ezno=${{ github.event.inputs.ezno-version }},ezno-parser=${{ github.event.inputs.ezno-parser-version }},ezno-checker=${{ github.event.inputs.ezno-checker-version }},${{ github.event.inputs.other-versions }}" | |
echo "::debug::$KEY_PAIR_ARGS" | |
KEY_PAIR_ARGS_JSON=$(echo $KEY_PAIR_ARGS | jq --raw-input --compact-output 'split(",") | map(select(length > 0 and . != "none")) | map_values(split("=") | { (.[0]): .[1] }) | reduce .[] as $o ({}; . + $o)') | |
echo "::debug::$KEY_PAIR_ARGS_JSON" | |
echo "publish-json-args=$KEY_PAIR_ARGS_JSON" >> $GITHUB_OUTPUT | |
shell: bash | |
- id: set-sponsors | |
run: | | |
SPONSORS=$(gh api graphql -f query='{ | |
user(login: "kaleidawave") { | |
sponsorshipsAsMaintainer(first: 100, activeOnly: false) { | |
edges { | |
node { | |
sponsor { | |
login | |
} | |
} | |
} | |
} | |
} | |
}' -q '.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.login) | join(", ")') | |
export SPONSORS | |
shell: bash | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Crates publish | |
uses: kaleidawave/crates-release-gh-action@main | |
id: release | |
with: | |
version: ${{ steps.set-arguments.outputs.publish-json-args }} | |
crates-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
- name: Push updated manifests | |
run: | | |
# Create tags | |
echo '${{ steps.release.outputs.new-versions }}' | jq -r '.[]' | while read -r update; do | |
git tag "release/$update" | |
done | |
if [[ ${{ github.event.inputs.ezno-version }} != 'none' ]]; then | |
git tag "release/main-$(echo '${{ steps.release.outputs.new-versions-json-object }}' | jq '.ezno' )" | |
fi | |
git add . | |
git commit -m "Release: ${{ steps.release.outputs.new-versions-description }}" | |
git push --tags origin main | |
sleep 20 | |
- name: Discord | |
uses: dusmartijngames/discord-webhook-notify@master | |
with: | |
severity: info | |
text: "Released version ${{ steps.release.outputs.new-versions-description }}" | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK_ENDPOINT }} |