-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (55 loc) · 1.96 KB
/
Copy pathrelease.yml
File metadata and controls
64 lines (55 loc) · 1.96 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
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-latest
steps:
- uses: actions/checkout@v4
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
moon test --target all
publish:
needs: test
if: vars.MOONCAKES_PUBLISH == 'true'
runs-on: ubuntu-latest
environment: mooncakes
steps:
- uses: actions/checkout@v4
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