-
-
Notifications
You must be signed in to change notification settings - Fork 46
154 lines (128 loc) · 5.53 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Release on Crates and NPM
on:
workflow_dispatch:
inputs:
ezno-version:
description: "major/minor/patch or semver for Ezno (CLI)"
required: false
default: "none"
ezno-checker-version:
description: "major/minor/patch or semver for the type checker"
required: false
default: "none"
ezno-parser-version:
description: "major/minor/patch or semver for the parser"
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:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
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=${{ inputs.ezno-version }},ezno-parser=${{ inputs.ezno-parser-version }},ezno-checker=${{ inputs.ezno-checker-version }},${{ 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
# Needed for WASM
- name: Get sponsors and contributors
id: get-sponsors-and-contributors
run: |
SQP='.data.user.sponsorshipsAsMaintainer.edges | map(.node.sponsor.name // .node.sponsor.login) | join(",")'
GQL_SQ='{ user(login: "kaleidawave") { sponsorshipsAsMaintainer(first: 100, activeOnly: false) { edges { node { sponsor { name, login } } } } } }'
SPONSORS=$(gh api graphql -f query="$GQL_SQ" -q "$SQP")
CQP='map(.author.name // .author.login) | unique | join(",")'
CONTRIBUTORS=$(gh pr list --state merged --json author | jq "$CQP" --raw-output)
echo "SPONSORS=$SPONSORS" >> "$GITHUB_OUTPUT"
echo "CONTRIBUTORS=$CONTRIBUTORS" >> "$GITHUB_OUTPUT"
echo "::notice::CONTRIBUTORS=$CONTRIBUTORS and SPONSORS=$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 }}
env:
SPONSORS: ${{ steps.get-sponsors-and-contributors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors-and-contributors.outputs.CONTRIBUTORS }}
- name: Add WASM to rustup
if: ${{ inputs.ezno-version != 'none' }}
run: rustup target add wasm32-unknown-unknown
- name: Set NPM package version & build
id: set-npm-version
if: ${{ inputs.ezno-version != 'none' }}
run: |
VERSION=$(echo '${{ steps.release.outputs.new-versions-json-object }}' | jq -r '.ezno')
echo "new-ezno-version=${VERSION}" >> $GITHUB_OUTPUT
npm ci
npm version $VERSION
npm run build-release
# TODO temp check
ls dist
working-directory: src/js-cli-and-library
env:
SPONSORS: ${{ steps.get-sponsors-and-contributors.outputs.SPONSORS }}
CONTRIBUTORS: ${{ steps.get-sponsors-and-contributors.outputs.CONTRIBUTORS }}
- name: NPM publish (CLI and library)
if: ${{ inputs.ezno-version != 'none' }}
uses: rxfork/npm-publish@v1
with:
token: ${{ secrets.NPM_REGISTRY_TOKEN }}
package: src/js-cli-and-library/package.json
- name: Update JS plugin version and dependencies
if: ${{ inputs.ezno-version != 'none' }}
run: |
# Hopefully propagated in 20 seconds
sleep 20
npm ci
npm install ezno@${{ steps.set-npm-version.outputs.new-ezno-version }}
npm version ${{ steps.set-npm-version.outputs.new-ezno-version }}
working-directory: src/js-based-plugin
- name: NPM publish (plugin)
uses: rxfork/npm-publish@v1
with:
token: ${{ secrets.NPM_REGISTRY_TOKEN }}
package: src/js-based-plugin/package.json
- name: Push updated manifests (Cargo.toml and package.json)
run: |
git add .
git commit -m "Release: ${{ steps.release.outputs.new-versions-description }}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Create tags
echo '${{ steps.release.outputs.new-versions }}' | jq -r '.[]' | while read -r update; do
git tag "release/$update"
done
git push --tags origin main
- 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 }}