Skip to content

Commit

Permalink
ci: release .jar for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesloetzsch committed Jul 25, 2021
1 parent 59a647b commit 2bbb3fe
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
37 changes: 35 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,58 @@ jobs:
- nix-{{ checksum "flake.lock" }} ## the cache will be cleaned on updates
- run:
name: Pure reproducible build + unit tests
command: nix build --show-trace
command: nix build -o result-fullstack --show-trace
- run:
name: Integration tests
command: |
nix build .#cypress -o result-cypress
export CYPRESS_BASE_URL="http://localhost:4000"
nix run &
(sleep 10; cd frontend; nix run ..#cypress -- run); EXIT=$?
kill $(cat .pid); exit $EXIT
- run:
name: Cleanup
command: |
du -hs /nix/store/
nix-collect-garbage
du -hs /nix/store/
- save_cache:
key: nix-{{ checksum "flake.lock" }}-{{ checksum "flake.nix" }}-{{ .BuildNum }}
paths:
- /nix/
release:
docker:
- image: johannesloetzsch/nix-flake:latest
steps:
- run:
name: Disable Sandbox
command: mkdir -p ~/.config/nix/; echo 'sandbox = false' >> ~/.config/nix/nix.conf;
- checkout
- restore_cache:
keys:
- nix-{{ checksum "flake.lock" }}-{{ checksum "flake.nix" }}
- nix-{{ checksum "flake.lock" }} ## the cache will be cleaned on updates
- run:
name: Release .jar
command: |
nix build .#fullstack.jar
nix run .#release result/*.jar swlkup.jar
workflows:
version: 2
default:
jobs:
- build-test:
filters: ## tags + branches
filters: ## branches + tags
branches:
only: /.*/
tags:
only: /.*/
- release:
filters: ## tags
branches:
ignore: /.*/
tags:
only: /.*/
requires:
- build-test
context: deployment
23 changes: 23 additions & 0 deletions .circleci/nix/tools/release.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ pkgs }:
(pkgs.writeScriptBin "deploy" ''
#!${pkgs.runtimeShell} -e
export PATH="${pkgs.stdenv.lib.makeBinPath (with pkgs; [github-release])}"
## $GITHUB_TOKEN must be a `personal access token` with scope `public_repo`.
## The owner of the token must be projekt owner of the repo.
[ -n "$GITHUB_TOKEN" ]
export GITHUB_USER="$CIRCLE_PROJECT_USERNAME"
export GITHUB_REPO="$CIRCLE_PROJECT_REPONAME"
export TAG="''${CIRCLE_TAG:-$CIRCLE_BRANCH}"
export FILE="$1"
export NAME="$2"
if github-release info -t $TAG ; then
github-release delete -t $TAG
fi
github-release release -t $TAG
github-release upload -t $TAG -f "$FILE" -n "$NAME"
'')
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
frontendCodegen = import ./frontend/nix/tools/codegen.nix { inherit pkgs; };
frontendUpdatedDeps = import ./frontend/nix/tools/updated-deps.nix { inherit pkgs; };
cypress = import ./frontend/nix/deps/cypress/override.nix { inherit pkgs; };
release = import ./.circleci/nix/tools/release.nix { inherit pkgs; };

## Builds
backend = import ./backend/nix/swlkup-backend.nix { inherit pkgs buildMavenRepositoryFromLockFile; };
Expand Down

0 comments on commit 2bbb3fe

Please sign in to comment.