stages: - check - update - build - release version_update: stage: update tags: - nix rules: - if: '$CI_PIPELINE_SOURCE == "web"' artifacts: reports: dotenv: update.env script: - nix run ".#update" > update.env - |- if git diff --quiet; then echo "Found changes to make" git checkout -b "sword-rev/$CI_PIPELINE_IID" echo "BRANCH=sword-rev/$CI_PIPELINE_IID" >> update.env git stage . git commit -m "Automatic update #$CI_PIPELINE_IID" git push "https://${GITLAB_USER_LOGIN}:${CI_GIT_TOKEN}@${CI_REPOSITORY_URL#*@}" HEAD fi create_pr: image: name: registry.gitlab.com/python-gitlab/python-gitlab:latest entrypoint: [ '' ] stage: update needs: - version_update dependencies: - version_update variables: GIT_STRATEGY: none GITLAB_PRIVATE_TOKEN: $CI_GIT_TOKEN rules: - if: '$CI_PIPELINE_SOURCE == "web"' script: - test -z ${DO_UPDATE} && { echo "No updates required. Not crating PR"; exit 0; } - >- CREATE_MR=$(gitlab project-merge-request create --remove-source-branch true --project-id ${CI_PROJECT_ID} --source-branch "${BRANCfh}" --target-branch "main" --title "Update sword to r$NEW_REV") - IID=${CREATE_MR#* } - >- gitlab project-merge-request merge \ --project-id ${CI_PROJECT_ID} \ --iid ${IID} \ --merge-when-pipeline-succeeds true - echo "PR set to auto-merge if build succeeds" check: stage: check rules: - if: '$CI_PIPELINE_SOURCE == "web"' when: never - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: '$CI_PIPELINE_SOURCE == "push"' tags: - nix script: - nix flake check - TAG=$(date +%Y.%m.%d).$CI_COMMIT_SHORT_SHA - echo "TAG=$TAG" > variables.env artifacts: reports: dotenv: variables.env build: stage: build needs: - job: check artifacts: true parallel: matrix: - ARCH: [x86, ucrt] tags: - nix rules: - if: '$CI_PIPELINE_SOURCE == "web"' when: never - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: '$CI_PIPELINE_SOURCE == "push"' script: - nix run -L ".#${ARCH}" - ls -l - URL=$CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic/sword-utils/$TAG/sword-${ARCH}-${TAG}.tar.xz - >- if [ "$CI_COMMIT_BRANCH" == "main" ]; then curl -i --fail-with-body --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./sword.tar.xz "${URL}" fi - echo "${ARCH}_TARBALL=${URL}" > "build.env.${ARCH}" artifacts: reports: dotenv: build.env.$ARCH "Create release": stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest tags: - docker rules: - if: '$CI_PIPELINE_SOURCE == "web"' when: never - if: $CI_COMMIT_BRANCH == "main" when: always needs: - job: check artifacts: true - job: build artifacts: true script: echo "Tagging as released" release: name: Release $TAG tag_name: "$TAG" description: Automatic SWORD utils build for Windows assets: links: - name: Windows (x86-64) release url: "${x86_TARBALL}" - name: Windows (x86-64) release with UCRT url: "${ucrt_TARBALL}"