Skip to content

Commit

Permalink
wip: nixify
Browse files Browse the repository at this point in the history
  • Loading branch information
pshirshov committed Oct 26, 2024
1 parent 2ce8ac8 commit ef56c8e
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 178 deletions.
155 changes: 0 additions & 155 deletions .build.sh

This file was deleted.

39 changes: 18 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,13 @@ jobs:
needs: [ 'checksecret' ]
strategy:
matrix:
java: [ '11' ]
scala: [ '2.12', '2.13', '3' ]
steps:
- uses: 7mind/github-env@main
with:
java-version: ${{ matrix.java }}
# - uses: actions/setup-go@v5
# with:
# go-version: '1.21.4' # The Go version to download (if necessary) and use.
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.x
- uses: 7mind/github-env@minimal
- name: Build and Test
run: |
bash sbtgen.sc --js
bash .build.sh ${{ matrix.scala }} coverage
env:
SCALA_VERSION: ${{ matrix.scala }}
run: ./build.sh nix gen coverage
- uses: bitwarden/sm-action@v2
if: needs.checksecret.outputs.HAVE_SECRETS == 'true'
with:
Expand All @@ -57,30 +48,28 @@ jobs:
# TODO: do we need scoverage.xml? If so files: may be just omitted
# files: cobertura.xml,scoverage.xml
# flags: unittests

publish-alien:
runs-on: ubuntu-latest
needs: [ 'checksecret' ]
if: needs.checksecret.outputs.HAVE_SECRETS == 'true'
steps:
- uses: 7mind/github-env@main
with:
java-version: 11
- uses: 7mind/github-env@minimal
- uses: bitwarden/sm-action@v2
with:
access_token: ${{ secrets.TOKEN_BITWARDEN_SM }}
secrets: |
637c5cad-a680-4ea3-ac8b-b193010bee40 > TOKEN_NUGET
aa0a790c-4030-4126-bc77-b193010a0f04 > TOKEN_NPM
- name: Publish alien artifacts
run: |
bash .build.sh 2.12 publishIDL
run: ./build.sh nix publish-alien

publish-artifacts:
runs-on: ubuntu-latest
needs: [ 'build', 'checksecret' ]
if: needs.checksecret.outputs.HAVE_SECRETS == 'true'
strategy:
matrix:
java: [ '11' ]
scala: [ '2.12', '2.13', '3' ]
steps:
- uses: 7mind/github-env@main
Expand All @@ -94,9 +83,17 @@ jobs:
749f4227-9f11-4ceb-9121-b1930110c3a9 > OPENSSL_KEY
a2fe5b5b-5f3f-47f8-961c-b1930110cea7 > OPENSSL_IV
- name: Build and Publish to Sonatype
env:
SONATYPE_SECRET: .secrets/credentials.sonatype-nexus.properties
run: |
bash sbtgen.sc --js
bash .build.sh ${{ matrix.scala }} secrets publishScala
if [[ "$CI_PULL_REQUEST" == "false" ]] ; then
mkdir .secrets
echo "$SONATYPE_CREDENTIALS_FILE" > "$SONATYPE_SECRET"
openssl aes-256-cbc -K ${OPENSSL_KEY} -iv ${OPENSSL_IV} -in secrets.tar.enc -out secrets.tar -d
tar xvf secrets.tar
fi
./build.sh nix gen publish-scala
all-good:
if: always()
runs-on: ubuntu-latest
Expand Down
27 changes: 27 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -e

self="$(realpath "$0")"
path="$(dirname "$self")"

(for e in "$@"; do [[ "$e" == "nix" ]] && exit 0; done) && NIXIFY=1 || NIXIFY=0

if [[ "$NIXIFY" == 1 && -z "${IN_NIX_SHELL+x}" ]]; then
echo "Restarting in Nix..."
set -x
nix flake lock
nix flake metadata
exec nix develop --command bash "$self" "$@"
fi

set -x
cd "$path"

for i in "$@"
do
case $i in
nix) ;;
*) "./devops/$i.sh" ;;
esac
done
23 changes: 23 additions & 0 deletions devops/.env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -e
set -x

export IZUMI_VERSION=$(cat version.sbt | sed -r 's/.*\"(.*)\".**/\1/' | sed -E "s/SNAPSHOT/build."${CI_BUILD_UNIQ_SUFFIX}"/")
export SCALA212=$(cat project/Deps.sc | grep 'val scala212 ' | sed -r 's/.*\"(.*)\".**/\1/')
export SCALA213=$(cat project/Deps.sc | grep 'val scala213 ' | sed -r 's/.*\"(.*)\".**/\1/')
export SCALA3=$(cat project/Deps.sc | grep 'val scala300 ' | sed -r 's/.*\"(.*)\".**/\1/')

[[ -z "$SCALA_VERSION" ]] && exit 1

case $SCALA_VERSION in
2.12) SCALA_VERSION="$SCALA212" ;;
2.13) SCALA_VERSION="$SCALA213" ;;
3) SCALA_VERSION="$SCALA3" ;;
*) exit 1 ;;
esac

export SCALA_VERSION="$SCALA_VERSION"
export VERSION_COMMAND="++ $SCALA_VERSION"

printenv
8 changes: 8 additions & 0 deletions devops/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -e
set -x

source ./devops/env.sh

sbt -batch -no-colors -v clean coverage "'$VERSION_COMMAND test'" "'$VERSION_COMMAND coverageReport'"
6 changes: 6 additions & 0 deletions devops/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -e
set -x

bash sbtgen.sc --js
18 changes: 18 additions & 0 deletions devops/publish-alien.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e
set -x

[[ "$CI_PULL_REQUEST" != "false" ]] && exit 0
[[ -z "$TOKEN_NUGET" ]] && exit 0
[[ -z "$TOKEN_NPM" ]] && exit 0
[[ ! ("$CI_BRANCH" == "develop" || "$CI_BRANCH_TAG" =~ ^v.*$ ) ]] && exit 0


echo "PUBLISH IDL RUNTIMES..."

echo "//registry.npmjs.org/:_authToken=${TOKEN_NPM}" > ~/.npmrc
npm whoami

./idealingua-v1/idealingua-v1-runtime-rpc-typescript/src/npmjs/publish.sh || exit 1
./idealingua-v1/idealingua-v1-runtime-rpc-csharp/src/main/nuget/publish.sh || exit 1
21 changes: 21 additions & 0 deletions devops/publish-scala.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -e
set -x

source ./devops/env.sh

[[ "$CI_PULL_REQUEST" != "false" ]] && exit 0
[[ -z "$TOKEN_NUGET" ]] && exit 0
[[ -z "$TOKEN_NPM" ]] && exit 0
[[ ! ("$CI_BRANCH" == "develop" || "$CI_BRANCH_TAG" =~ ^v.*$ ) ]] && exit 0
[[ -f "$SONATYPE_SECRET"]] && exit 0


echo "PUBLISH SCALA LIBRARIES..."

if [[ "$CI_BRANCH" == "develop" ]] ; then
sbt -batch -no-colors -v "'$VERSION_COMMAND clean'" "'$VERSION_COMMAND package'" "'$VERSION_COMMAND publishSigned'"
else
sbt -batch -no-colors -v "'$VERSION_COMMAND clean'" "'$VERSION_COMMAND package'" "'$VERSION_COMMAND publishSigned'" sonatypeBundleRelease || exit 1
fi
Loading

0 comments on commit ef56c8e

Please sign in to comment.