diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 01c55db12..0df25fe1f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,6 @@ default: variables: NIX_PATH: "nixpkgs=http://nixos.org/channels/nixos-21.05/nixexprs.tar.xz" AWS_SHARED_CREDENTIALS_FILE: "/etc/aws/credentials" - FLAKE: "git+${CI_REPOSITORY_URL}?rev=${CI_COMMIT_SHA}" TRANSFER_METER_FREQUENCY: "2s" @@ -26,6 +25,7 @@ stages: node dependencies: stage: frontend:build script: + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworxNodeDependencies" - nix-store --export $(nix-store -qR result) | xz -T0 -2 > node-dependencies.nar.xz before_script: &nix-before @@ -57,6 +57,7 @@ well known: stage: frontend:build script: - xzcat node-dependencies.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworxWellKnown" - nix-store --export $(nix-store -qR result) | xz -T0 -2 > well-known.nar.xz before_script: *nix-before @@ -76,6 +77,7 @@ frontend: script: - xzcat node-dependencies.nar.xz | nix-store --import - xzcat well-known.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworxFrontend" - nix-store --export $(nix-store -qR result) | xz -T0 -2 > frontend.nar.xz before_script: *nix-before @@ -96,6 +98,7 @@ uniworx:lib:uniworx: stage: backend:build script: - xzcat frontend.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworx:lib:uniworx" - nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:lib:uniworx.nar.xz before_script: *nix-before @@ -118,6 +121,7 @@ uniworx:exe:uniworx: stage: backend:build script: - xzcat uniworx:lib:uniworx.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworx:exe:uniworx" - nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworx.nar.xz before_script: *nix-before @@ -142,6 +146,7 @@ uniworx:exe:uniworx-wflint: stage: backend:build script: - xzcat uniworx:lib:uniworx.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworx:exe:uniworx-wflint" - nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworx-wflint.nar.xz before_script: *nix-before @@ -166,6 +171,7 @@ uniworx:exe:uniworxdb: stage: backend:build script: - xzcat uniworx:lib:uniworx.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworx:exe:uniworxdb" - nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworxdb.nar.xz before_script: *nix-before @@ -190,6 +196,7 @@ uniworx:exe:uniworxload: stage: backend:build script: - xzcat uniworx:lib:uniworx.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworx:exe:uniworxload" - nix-store --export $(nix-store -qR result) | xz -T0 -2 > uniworx:exe:uniworxload.nar.xz before_script: *nix-before @@ -215,7 +222,8 @@ check: script: - xzcat frontend.nar.xz | nix-store --import - xzcat uniworx:lib:uniworx.nar.xz | nix-store --import - - nix -L flake check + - source .gitlab-ci/construct-flake-url.sh + - nix -L flake check ${FLAKE} before_script: *nix-before needs: - job: node dependencies # transitive @@ -234,6 +242,7 @@ demo docker: script: - xzcat uniworx:exe:uniworx.nar.xz | nix-store --import - xzcat uniworx:exe:uniworxdb.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworxDemoDocker" - cp -pr --reflink=auto -L result uniworx-demo.tar.gz before_script: *nix-before @@ -268,6 +277,7 @@ docker: stage: docker script: - xzcat uniworx:exe:uniworx.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L build -o result "${FLAKE}#uniworxDocker" - cp -pr --reflink=auto -L result uniworx.tar.gz before_script: *nix-before @@ -307,6 +317,7 @@ parse changelog: before_script: *nix-before script: - xzcat node-dependencies.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L run "${FLAKE}#jqChangelogJson" -- -r '.versions[0].version' > .current-version - nix -L run "${FLAKE}#jqChangelogJson" -- -r '.versions[0].body' > .current-changelog.md - echo "VERSION=$(cat .current-version)" >> build.env @@ -325,6 +336,7 @@ upload docker: stage: docker script: - xzcat uniworx:exe:uniworx.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L run "${FLAKE}#pushUniworxDocker" before_script: *nix-before needs: @@ -349,6 +361,7 @@ upload demo docker: script: - xzcat uniworx:exe:uniworx.nar.xz | nix-store --import - xzcat uniworx:exe:uniworxdb.nar.xz | nix-store --import + - source .gitlab-ci/construct-flake-url.sh - nix -L run "${FLAKE}#pushUniworxDemoDocker" before_script: *nix-before needs: diff --git a/.gitlab-ci/construct-flake-url.sh b/.gitlab-ci/construct-flake-url.sh new file mode 100644 index 000000000..0f4f10787 --- /dev/null +++ b/.gitlab-ci/construct-flake-url.sh @@ -0,0 +1,6 @@ +if [ -n "${CI_COMMIT_TAG}" ]; then + ref="refs/tags/${CI_COMMIT_TAG}" +else + ref="refs/heads/${CI_COMMIT_BRANCH}" +fi +export FLAKE="git+${CI_REPOSITORY_URL}?rev=${CI_COMMIT_SHA}&ref=${ref}"