|
| 1 | +# First stage of CI: create the `sdist` and Cranko release commit. |
| 2 | + |
| 3 | +jobs: |
| 4 | + |
| 5 | +- job: sdist |
| 6 | + pool: |
| 7 | + vmImage: ubuntu-latest |
| 8 | + |
| 9 | + # Need Zenodo credentials to generate DOIs during formal releases. Try not to |
| 10 | + # provide credentials otherwise, in case of malicious PRs. But note that such |
| 11 | + # a PR could just remove this filter anyway -- that's why modern CI systems |
| 12 | + # don't provide secrets during PR builds in the first place. |
| 13 | + ${{ if and(eq(variables['Build.SourceBranchName'], 'rc'), ne(variables['build.reason'], 'PullRequest')) }}: |
| 14 | + variables: |
| 15 | + - group: Deployment Credentials |
| 16 | + |
| 17 | + steps: |
| 18 | + |
| 19 | + - checkout: self |
| 20 | + |
| 21 | + - bash: | |
| 22 | + set -euo pipefail |
| 23 | + d="$(mktemp -d /tmp/cranko.XXXXXX)" |
| 24 | + cd "$d" |
| 25 | + curl --proto '=https' --tlsv1.2 -sSf https://pkgw.github.io/cranko/fetch-latest.sh | sh |
| 26 | + echo "##vso[task.prependpath]$d" |
| 27 | + displayName: Install latest Cranko |
| 28 | +
|
| 29 | + - bash: cranko release-workflow apply-versions |
| 30 | + displayName: Apply Cranko versions |
| 31 | + |
| 32 | + - bash: cranko zenodo preregister --metadata=ci/zenodo.json5 pwkit CHANGELOG.md |
| 33 | + displayName: "Preregister Zenodo DOI" |
| 34 | + ${{ if and(eq(variables['Build.SourceBranchName'], 'rc'), ne(variables['build.reason'], 'PullRequest')) }}: |
| 35 | + env: |
| 36 | + ZENODO_TOKEN: $(ZENODO_TOKEN) |
| 37 | + |
| 38 | + - bash: | |
| 39 | + set -xeuo pipefail |
| 40 | + git add . |
| 41 | + cranko release-workflow commit |
| 42 | + git show |
| 43 | + displayName: Make release commit |
| 44 | +
|
| 45 | + # Note: in order for Cranko to work at all, and this step in particular, |
| 46 | + # "shallow" Git checkouts must be disabled in the project's Azure pipelines |
| 47 | + # configuration. |
| 48 | + - bash: | |
| 49 | + artifact_dir="$(Build.ArtifactStagingDirectory)/git-release" |
| 50 | + mkdir -p "$artifact_dir" |
| 51 | + git bundle create "$artifact_dir/release.bundle" origin/master..HEAD |
| 52 | + displayName: Bundle release commit |
| 53 | +
|
| 54 | + - task: PublishPipelineArtifact@1 |
| 55 | + displayName: Publish release git bundle artifact |
| 56 | + inputs: |
| 57 | + targetPath: '$(Build.ArtifactStagingDirectory)/git-release' |
| 58 | + artifactName: git-release |
| 59 | + |
| 60 | + # TODO: it seems that at the moment, there is no better way to create an |
| 61 | + # sdist than to invoke setup.py directly. People seem to be working on |
| 62 | + # alternatives but nothing is official yet. |
| 63 | + |
| 64 | + - bash: | |
| 65 | + set -euo pipefail |
| 66 | + eval "$($CONDA/bin/conda shell.bash hook)" |
| 67 | + set -x |
| 68 | + conda activate |
| 69 | + conda config --add channels conda-forge |
| 70 | + conda install -y numpy |
| 71 | + displayName: Set up dependencies |
| 72 | +
|
| 73 | + - bash: | |
| 74 | + set -euo pipefail |
| 75 | + eval "$($CONDA/bin/conda shell.bash hook)" |
| 76 | + conda activate |
| 77 | + set -x |
| 78 | + python setup.py sdist |
| 79 | + tar tzf dist/*.tar.gz |sort |
| 80 | + displayName: Create sdist |
| 81 | +
|
| 82 | + - task: PublishPipelineArtifact@1 |
| 83 | + displayName: Publish sdist artifact |
| 84 | + inputs: |
| 85 | + targetPath: dist |
| 86 | + artifactName: sdist |
0 commit comments