Skip to content

Commit

Permalink
Merge pull request #178 from ConorMacBride/upgrade-artifact-v4
Browse files Browse the repository at this point in the history
Upgrade `upload-artifact` and `download-artifact` actions from `v3` to `v4`
  • Loading branch information
Cadair authored Jan 29, 2024
2 parents 8b72ce8 + 6e927a3 commit 36c724c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
- run: python -m pip install PyYAML click
- run: echo $LOAD_BUILD_TARGETS_SCRIPT | base64 --decode > load_build_targets.py
env:
LOAD_BUILD_TARGETS_SCRIPT: aW1wb3J0IGpzb24KaW1wb3J0IG9zCgppbXBvcnQgY2xpY2sKaW1wb3J0IHlhbWwKCk1BQ0hJTkVfVFlQRSA9IHsKICAgICJsaW51eCI6ICJ1YnVudHUtbGF0ZXN0IiwKICAgICJtYWNvcyI6ICJtYWNvcy1sYXRlc3QiLAogICAgIndpbmRvd3MiOiAid2luZG93cy1sYXRlc3QiLAp9CgpDSUJXX0JVSUxEID0gb3MuZW52aXJvbi5nZXQoIkNJQldfQlVJTEQiLCAiKiIpCkNJQldfQVJDSFMgPSBvcy5lbnZpcm9uLmdldCgiQ0lCV19BUkNIUyIsICJhdXRvIikKCgpAY2xpY2suY29tbWFuZCgpCkBjbGljay5vcHRpb24oIi0tdGFyZ2V0cyIsIGRlZmF1bHQ9IiIpCmRlZiBsb2FkX2J1aWxkX3RhcmdldHModGFyZ2V0cyk6CiAgICAiIiJTY3JpcHQgdG8gbG9hZCBjaWJ1aWxkd2hlZWwgdGFyZ2V0cyBmb3IgR2l0SHViIEFjdGlvbnMgd29ya2Zsb3cuIiIiCiAgICAjIExvYWQgbGlzdCBvZiB0YXJnZXRzCiAgICB0YXJnZXRzID0geWFtbC5sb2FkKHRhcmdldHMsIExvYWRlcj15YW1sLkJhc2VMb2FkZXIpCiAgICBwcmludChqc29uLmR1bXBzKHRhcmdldHMs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c3ViKHIiLSsiLCAiLSIsIGFydGlmYWN0X25hbWUpCiAgICByZXR1cm4gYXJ0aWZhY3RfbmFtZQoKCmRlZiBnZXRfbWF0cml4X2l0ZW0odGFyZ2V0KToKICAgIHJldHVybiB7CiAgICAgICAgInRhcmdldCI6IHRhcmdldCwKICAgICAgICAib3MiOiBnZXRfb3ModGFyZ2V0KSwKICAgICAgICAiQ0lCV19CVUlMRCI6IGdldF9jaWJ3X2J1aWxkKHRhcmdldCksCiAgICAgICAgIkNJQldfQVJDSFMiOiBnZXRfY2lid19hcmNocyh0YXJnZXQpLAogICAgICAgICJhcnRpZmFjdC1uYW1lIjogZ2V0X2FydGlmYWN0X25hbWUodGFyZ2V0KSwKICAgIH0KCgppZiBfX25hbWVfXyA9PSAiX19tYWluX18iOgogICAgbG9hZF9idWlsZF90YXJnZXRzKCkK
- id: set-outputs
run: python load_build_targets.py --targets "${{ inputs.targets }}"
shell: sh
Expand Down Expand Up @@ -189,10 +189,11 @@ jobs:
env:
CIBW_BUILD: ${{ matrix.CIBW_BUILD }}
CIBW_ARCHS: ${{ matrix.CIBW_ARCHS }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: |
needs.targets.outputs.upload_to_pypi == 'true' || inputs.upload_to_anaconda
with:
name: "dist-${{ matrix.artifact-name }}"
path: dist/*

build_sdist:
Expand Down Expand Up @@ -232,10 +233,11 @@ jobs:
test_extras: ${{ inputs.test_extras }}
test_command: ${{ inputs.test_command }}
pure_python_wheel: false
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: |
needs.targets.outputs.upload_to_pypi == 'true' || inputs.upload_to_anaconda
with:
name: dist-sdist
path: dist/*

upload:
Expand All @@ -250,10 +252,11 @@ jobs:
needs.build_wheels.result != 'failure' &&
needs.build_sdist.result != 'failure'
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
pattern: dist-*
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
name: Upload to PyPI
if: ${{ needs.targets.outputs.upload_to_pypi == 'true' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
needs: [test_artifact_upload]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact-upload-(ubuntu-latest)
path: .
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ jobs:
shell: sh

- if: ${{ (success() || failure()) && matrix.artifact-path != '' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.artifact-path }}
Expand Down
8 changes: 8 additions & 0 deletions tools/load_build_targets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import re

import click
import yaml
Expand Down Expand Up @@ -54,12 +55,19 @@ def get_cibw_archs(target):
return CIBW_ARCHS


def get_artifact_name(target):
artifact_name = re.sub(r"[\\ /:<>|*?\"']", "-", target)
artifact_name = re.sub(r"-+", "-", artifact_name)
return artifact_name


def get_matrix_item(target):
return {
"target": target,
"os": get_os(target),
"CIBW_BUILD": get_cibw_build(target),
"CIBW_ARCHS": get_cibw_archs(target),
"artifact-name": get_artifact_name(target),
}


Expand Down

0 comments on commit 36c724c

Please sign in to comment.