Repository navigation
106 lines (93 loc) · 3.67 KB
/
Copy pathrelease.yml
File metadata and controls
106 lines (93 loc) · 3.67 KB
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
name: Release
# A version tag publishes this module to mooncakes under the moonbitstack account. Publishing is
# opt-in: the publish job runs only while the organization (or repository) variable
# MOONCAKES_PUBLISH is 'true', so a tag with the switch off only runs the tests.
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-26.04
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: install moonbit
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
- name: test
run: |
moon update
moon check --target all --deny-warn
moon test --target all
publish:
needs: test
if: vars.MOONCAKES_PUBLISH == 'true'
runs-on: ubuntu-26.04
environment: mooncakes
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: install moonbit
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
- name: check tag and namespace
run: |
version="$(sed -n 's/^version = "\(.*\)"/\1/p' moon.mod)"
grep -q '^name = "moonbitstack/' moon.mod || { echo "::error::moon.mod is not under moonbitstack"; exit 1; }
if [ "$GITHUB_REF_TYPE" = tag ] && [ "${GITHUB_REF_NAME##*v}" != "$version" ]; then
echo "::error::tag $GITHUB_REF_NAME does not match moon.mod version $version"; exit 1
fi
- name: publish
env:
CREDENTIALS: ${{ secrets.MOONCAKES_CREDENTIALS }}
run: |
if [ -z "$CREDENTIALS" ]; then echo "::error::MOONCAKES_CREDENTIALS is not available"; exit 1; fi
trap 'rm -f ~/.moon/credentials.json' EXIT
printf '%s' "$CREDENTIALS" > ~/.moon/credentials.json
moon update
moon publish
# Tell the organisation site a new version exists, so the catalogue it
# publishes stops needing an edit per release. Without the token the step
# says so and the site's half-monthly run picks the version up instead.
- name: tell the site
env:
TOKEN: ${{ secrets.SITE_DISPATCH_TOKEN }}
run: |
if [ -z "$TOKEN" ]; then echo "no SITE_DISPATCH_TOKEN — the site will catch up on its own"; exit 0; fi
curl -fsS -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/moonbitstack/moonbitstack.github.io/dispatches \
-d '{"event_type":"released"}'
# Its own job: the module is already out by now, so rerunning a failure here must not publish it again.
skills:
needs: publish
runs-on: ubuntu-26.04
environment: mooncakes
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: install moonbit
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
echo "$HOME/.moon/bin" >> "$GITHUB_PATH"
- name: publish the skills, at the module's version
env:
CREDENTIALS: ${{ secrets.MOONCAKES_CREDENTIALS }}
run: |
version="$(sed -n 's/^version = "\(.*\)"/\1/p' moon.mod)"
trap 'rm -f ~/.moon/credentials.json' EXIT
printf '%s' "$CREDENTIALS" > ~/.moon/credentials.json
moon update
for dir in docs/skills/*/; do
[ -f "$dir/SKILL.md" ] || continue
moonx moonbit-community/skills --moon-home "$HOME/.moon" publish "$dir" --version "$version"
done