Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: 7mind/github-env@minimal
- name: Run test build
run: ./run --nix :test
run: nix develop --command mdl --github-actions :test

publish-scala:
runs-on: ubuntu-latest
Expand All @@ -45,7 +45,7 @@ jobs:
popd
fi

./run --nix :publish-scala
nix develop --command mdl --github-actions :publish-scala

publish-sjs:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
popd
fi

./run --nix :build-sjs
nix develop --command mdl --github-actions :build-sjs
- uses: softprops/action-gh-release@v2
id: create-release
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -86,7 +86,7 @@ jobs:
./json-sick-scala/target/dist/**
- name: Prepare and Publish to npm
if: startsWith(github.ref, 'refs/tags/')
run: ./run --nix :publish-npm
run: nix develop --command mdl --github-actions :publish-npm

publish-cs:
runs-on: ubuntu-latest
Expand All @@ -101,4 +101,4 @@ jobs:
secrets: |
637c5cad-a680-4ea3-ac8b-b193010bee40 > TOKEN_NUGET
- name: Build and Test
run: ./run --nix :publish-cs
run: nix develop --command mdl --github-actions :publish-cs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target
.bsp
metals.sbt
.direnv
.mdl/runs

npm-publish
node_modules/
Expand Down
207 changes: 207 additions & 0 deletions .mdl/defs/actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# SICK Build Actions

# environment
- `LANG=C.UTF-8`

## passthrough
- `HOME`
- `USER`
- `CI_BRANCH`
- `CI_BRANCH_TAG`
- `CI_BUILD_UNIQ_SUFFIX`
- `CI_PULL_REQUEST`
- `TOKEN_NUGET`
- `NODE_AUTH_TOKEN`

# action: clean-worktree

```bash
set -euo pipefail

PROJECT_ROOT="${sys.project-root}"
cd "$PROJECT_ROOT"

git clean -fxd -e private -e .idea -e .mdl -e .mdl/runs

ret cleaned:bool=true
```

# action: test-scala

```bash
dep action.clean-worktree

set -euo pipefail

SCALA_DIR="${sys.project-root}/json-sick-scala"
cd "$SCALA_DIR"

sbt +clean +test:compile +test

ret success:bool=true
```

# action: test-csharp

```bash
dep action.test-scala

set -euo pipefail

CS_DIR="${sys.project-root}/json-sick-csharp"
cd "$CS_DIR"

dotnet build
dotnet test

ret success:bool=true
```

# action: test

```bash
dep action.test-csharp

ret success:bool=true
```

# action: publish-scala

```bash
set -euo pipefail

SCALA_DIR="${sys.project-root}/json-sick-scala"

CI_PULL_REQUEST_VAL="${CI_PULL_REQUEST:-true}"
CI_BRANCH_TAG_VAL="${CI_BRANCH_TAG:-}"

if [[ "$CI_PULL_REQUEST_VAL" != "false" ]]; then
echo "Skipping Scala publish because this is a pull request."
ret skipped:bool=true
exit 0
fi

if [[ -z "$CI_BRANCH_TAG_VAL" ]]; then
echo "CI_BRANCH_TAG is required to publish Scala artifacts." >&2
exit 1
fi

cd "$SCALA_DIR"

if [[ "$CI_BRANCH_TAG_VAL" =~ ^v.*$ ]]; then
sbt +clean +compile +publishSigned sonaUpload sonaRelease
sbt '++2.13 json-sickJS/fullOptJS'
else
sbt +clean +compile +publishSigned
fi

ret success:bool=true
```

# action: build-sjs

```bash
set -euo pipefail

SCALA_DIR="${sys.project-root}/json-sick-scala"
DIST_DIR="${SCALA_DIR}/target/dist"

CI_PULL_REQUEST_VAL="${CI_PULL_REQUEST:-true}"
if [[ "$CI_PULL_REQUEST_VAL" != "false" ]]; then
echo "Skipping Scala.js build because this is a pull request."
mkdir -p "$DIST_DIR"
ret skipped:bool=true
ret dist-dir:directory="$DIST_DIR"
exit 0
fi

cd "$SCALA_DIR"
sbt '++2.13 json-sickJS/fullOptJS'

ret dist-dir:directory="$DIST_DIR"
```

# action: publish-cs

```bash
set -euo pipefail

CI_PULL_REQUEST_VAL="${CI_PULL_REQUEST:-true}"
TOKEN_NUGET_VAL="${TOKEN_NUGET:-}"
CI_BUILD_UNIQ_SUFFIX_VAL="${CI_BUILD_UNIQ_SUFFIX:-}"
CI_BRANCH_TAG_VAL="${CI_BRANCH_TAG:-}"

if [[ "$CI_PULL_REQUEST_VAL" != "false" ]]; then
echo "Skipping C# publish because this is a pull request."
ret skipped:bool=true
exit 0
fi

if [[ -z "$TOKEN_NUGET_VAL" ]]; then
echo "TOKEN_NUGET is required to publish C# artifacts; skipping." >&2
ret skipped:bool=true
exit 0
fi

if [[ -z "$CI_BUILD_UNIQ_SUFFIX_VAL" ]]; then
echo "CI_BUILD_UNIQ_SUFFIX is required to publish C# artifacts; skipping." >&2
ret skipped:bool=true
exit 0
fi

CS_DIR="${sys.project-root}/json-sick-csharp"
cd "$CS_DIR"

if [[ "$CI_BRANCH_TAG_VAL" =~ ^v.*$ ]]; then
dotnet build -c Release
else
dotnet build -c Release --version-suffix "alpha.${CI_BUILD_UNIQ_SUFFIX_VAL}"
fi

find . -name '*.nupkg' -type f -print0 | xargs -I % -n 1 -0 dotnet nuget push % -k "${TOKEN_NUGET_VAL}" --source https://api.nuget.org/v3/index.json

ret success:bool=true
```

# action: publish-npm

```bash
dep action.build-sjs

set -euo pipefail

CI_PULL_REQUEST_VAL="${CI_PULL_REQUEST:-true}"
if [[ "$CI_PULL_REQUEST_VAL" != "false" ]]; then
echo "Skipping npm publish because this is a pull request."
ret skipped:bool=true
exit 0
fi

PROJECT_ROOT="${sys.project-root}"
DIST_DIR="${action.build-sjs.dist-dir}"
PUBLISH_DIR="${PROJECT_ROOT}/npm-publish"
VERSION_FILE="${PROJECT_ROOT}/version.txt"
VERSION=$(tr -d '\n' < "$VERSION_FILE")

if [[ ! -d "$DIST_DIR" ]]; then
echo "Scala.js distribution directory '$DIST_DIR' is missing." >&2
exit 1
fi

rm -rf "$PUBLISH_DIR"
mkdir -p "$PUBLISH_DIR"

cp "${DIST_DIR}"/* "$PUBLISH_DIR"/
cp "${PROJECT_ROOT}/json-sick-scala/npm-template/"* "$PUBLISH_DIR"/

sed -i "s/VERSION_PLACEHOLDER/$VERSION/g" "$PUBLISH_DIR/package.json"

cd "$PUBLISH_DIR"

npm install --save-dev ava
npm test
npm publish --provenance --access public

ret success:bool=true
ret publish-dir:directory="$PUBLISH_DIR"
```
10 changes: 0 additions & 10 deletions .mobala/env.sh

This file was deleted.

11 changes: 0 additions & 11 deletions .mobala/flows/do-build.sh

This file was deleted.

1 change: 0 additions & 1 deletion .mobala/keep.env

This file was deleted.

11 changes: 0 additions & 11 deletions .mobala/steps/run-build-sjs.sh

This file was deleted.

19 changes: 0 additions & 19 deletions .mobala/steps/run-publish-cs.sh

This file was deleted.

23 changes: 0 additions & 23 deletions .mobala/steps/run-publish-npm.sh

This file was deleted.

16 changes: 0 additions & 16 deletions .mobala/steps/run-publish-scala.sh

This file was deleted.

19 changes: 0 additions & 19 deletions .mobala/steps/run-test.sh

This file was deleted.

2 changes: 0 additions & 2 deletions .mobala/version-commit.lock

This file was deleted.

1 change: 0 additions & 1 deletion .mobala/version.txt

This file was deleted.

Loading