|
| 1 | +name: zenodo |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + tag: |
| 7 | + description: "Git tag to upload (e.g. v1.1.0). Leave blank to use latest tag." |
| 8 | + required: false |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + zenodo: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: determine tag |
| 22 | + id: tag |
| 23 | + run: | |
| 24 | + git fetch --tags |
| 25 | + if [ -z "${{ inputs.tag }}" ]; then |
| 26 | + TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)") |
| 27 | + else |
| 28 | + TAG=${{ inputs.tag }} |
| 29 | + fi |
| 30 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 31 | + echo "Uploading tag: $TAG" |
| 32 | +
|
| 33 | + - name: checkout tag |
| 34 | + run: | |
| 35 | + git checkout ${{ steps.tag.outputs.tag }} |
| 36 | +
|
| 37 | + - uses: actions/setup-python@v5 |
| 38 | + with: |
| 39 | + python-version: "3.10" |
| 40 | + |
| 41 | + - run: | |
| 42 | + python -m pip install --upgrade pip build requests |
| 43 | + chmod +x scripts/zenodo_upload.py |
| 44 | +
|
| 45 | + - name: build package |
| 46 | + run: python -m build |
| 47 | + |
| 48 | + - name: zip source (for Zenodo) |
| 49 | + run: | |
| 50 | + mkdir -p release_assets |
| 51 | + cp -r dist release_assets/ |
| 52 | + (cd release_assets && zip -r "source-${{ steps.tag.outputs.tag }}.zip" dist) |
| 53 | +
|
| 54 | + - name: upload to Zenodo |
| 55 | + env: |
| 56 | + ZENODO_TOKEN: ${{ secrets.ZENODO_TOKEN }} |
| 57 | + ZENODO_API_URL: "https://zenodo.org/api" |
| 58 | + ZENODO_DEPOSITION_ID: ${{ vars.ZENODO_DEPOSITION_ID }} |
| 59 | + ZENODO_TITLE: ${{ vars.ZENODO_TITLE }} |
| 60 | + ZENODO_DESCRIPTION: ${{ vars.ZENODO_DESCRIPTION }} |
| 61 | + ZENODO_AUTHORS: ${{ vars.ZENODO_AUTHORS }} |
| 62 | + ZENODO_COMMUNITIES: ${{ vars.ZENODO_COMMUNITIES }} |
| 63 | + ZENODO_KEYWORDS: ${{ vars.ZENODO_KEYWORDS }} |
| 64 | + VERSION: ${{ steps.tag.outputs.tag }} |
| 65 | + FILEPATH: release_assets/source-${{ steps.tag.outputs.tag }}.zip |
| 66 | + run: | |
| 67 | + python scripts/zenodo_upload.py |
0 commit comments