-
Notifications
You must be signed in to change notification settings - Fork 48
138 lines (132 loc) · 5.1 KB
/
main.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
name: main
on:
push:
branches:
- "**"
tags:
- "**"
pull_request:
branches:
- "**"
jobs:
build-and-test:
name: "build-and-test (${{ matrix.configuration }})"
strategy:
matrix:
configuration: ["Release"]
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Check if .Libplanet refers to a tagged commit
if: |
github.event_name == 'push' && (
github.ref == 'refs/heads/main' ||
startsWith(github.ref, 'refs/heads/rc-') ||
startsWith(github.ref, 'refs/tags/')
) ||
github.event_name == 'pull_request' && (
github.head_ref == 'refs/heads/main' ||
startsWith(github.head_ref, 'refs/heads/rc-') ||
startsWith(github.head_ref, 'refs/tags/')
)
run: |
set -e
pushd .Libplanet/
git fetch origin 'refs/tags/*:refs/tags/*'
if ! git describe --tags --exact-match; then
echo "The unreleased Libplanet shouldn't be used." > /dev/stderr
exit 1
fi
popd
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.400
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --self-contained=false --no-restore --configuration ${{ matrix.configuration }}
- name: Test
run: dotnet test --no-restore --verbosity normal --configuration ${{ matrix.configuration }}
build-for-unity:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.400
- name: Enforce netstandard2.1 target with custom patch
run: |
set -e
sed -i -E 's|<TargetFramework>.*</TargetFramework>|<TargetFramework>netstandard2.1</TargetFramework>|' Lib9c*/*.csproj Libplanet*/*.csproj
sed -i -E 's|<ImplicitUsings>.*</ImplicitUsings>|<ImplicitUsings>disable</ImplicitUsings>|' Lib9c*/*.csproj Libplanet*/*.csproj
sed -i -E 's|\[MaybeNullWhen\(false\)] out TValue value|out TValue value|' Lib9c/TableData/Sheet.cs
sed -i -E 's|public bool TryGetValue\(TKey key, out TValue value, bool throwException\)|public bool TryGetValue\(TKey key, out TValue? value, bool throwException\)|' Lib9c/TableData/Sheet.cs
- name: build
run: dotnet build --self-contained=false
release:
if: github.ref_type == 'tag' && startsWith(github.ref_name, 'v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Check if a new tag refers a merge commit
if: github.ref_type == 'tag'
run: |
set -evx
curl -o /tmp/web-flow.gpg "$WEB_FLOW_KEY_URL"
gpg --import /tmp/web-flow.gpg
# shellcheck disable=SC2126
if ! git verify-commit "$GITHUB_REF_NAME" && \
[[ "$( git cat-file -p "$GITHUB_REF_NAME" \
| grep -Ei '^parent\s+[0-9a-f]{40}$' | wc -l )" -lt 2 ]]; then
echo "::error title=Invalid tag commit::Tags must refer to a merge" \
"commit or a commit signed by GitHub web-flow" \
"($WEB_FLOW_KEY_URL). The tag $GITHUB_REF_NAME refers to " \
"a commit $(git rev-parse "$GITHUB_REF_NAME") which is neither" \
"a merge commit nor signed by GitHub web-flow."
exit 1
fi
env:
WEB_FLOW_KEY_URL: https://github.com/web-flow.gpg
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.400
- name: Collect available action type ids
run: |
mkdir publish
dotnet run --property WarningLevel=0 --project .Lib9c.Tools/Lib9c.Tools.csproj -- action list > publish/all_action_type_ids.txt
dotnet run --property WarningLevel=0 --project .Lib9c.Tools/Lib9c.Tools.csproj -- action list --obsolete-only --json-path=publish/obsolete_action_types.json
- name: Publish available action type ids
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./publish
destination_dir: ${{ github.ref_name }}
- name: Publish available action type ids for latest
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./publish
destination_dir: latest
update-submodule:
if: github.ref_type == 'branch' && startsWith(github.ref_name, 'release/')
runs-on: ubuntu-latest
steps:
- name: Update other repos referring lib9c as submodules
uses: planetarium/submodule-updater@main
with:
token: ${{ secrets.SUBMODULE_UPDATER_GH_TOKEN }}
committer: >
Submodule Updater <[email protected]>
targets: |
planetarium/NineChronicles:refs/heads/release/*
${{ github.repository_owner }}/NineChronicles.Headless:refs/heads/release/*
${{ github.repository_owner }}/market-service:refs/heads/release/*