mirror of
https://github.com/pyTooling/Actions.git
synced 2026-02-12 02:56:56 +08:00
add option 'rm' (#156)
This commit is contained in:
9
.github/workflows/test.yml
vendored
9
.github/workflows/test.yml
vendored
@@ -18,21 +18,22 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: echo "Build some tool and generate some artifacts" > artifact.txt
|
||||
|
||||
- run: echo "Build some tool and generate some (versioned) artifacts" > artifact-$(date -u +"%Y-%m-%dT%H-%M-%SZ").txt
|
||||
|
||||
- name: Single
|
||||
uses: ./
|
||||
with:
|
||||
rm: true
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: artifact.txt
|
||||
files: artifact-*.txt
|
||||
|
||||
- name: List
|
||||
uses: ./
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
files: |
|
||||
artifact.txt
|
||||
artifact-*.txt
|
||||
README.md
|
||||
|
||||
- run: |
|
||||
|
||||
@@ -36,3 +36,5 @@ jobs:
|
||||
Note that the tag and the pre-release need to be created manually the first time. The workflow above will fail if the release does not exist.
|
||||
|
||||
The default tag name is `tip`, but it can be optionally overriden through option `tag` or setting envvar `INPUT_TAG`.
|
||||
|
||||
If you systematically want to remove previous artifacts (e.g. old versions), set the `rm` option to true.
|
||||
|
||||
@@ -11,6 +11,10 @@ inputs:
|
||||
description: 'Name of the tag that corresponds to the tip/nightly pre-release'
|
||||
required: false
|
||||
default: tip
|
||||
rm:
|
||||
description: 'Whether to delete all the previous artifacts, or only replacing the ones with the same name'
|
||||
required: false
|
||||
default: false
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
|
||||
30
tip.py
30
tip.py
@@ -68,18 +68,24 @@ print("· Upload artifacts")
|
||||
|
||||
artifacts = files
|
||||
|
||||
for asset in gh_release.get_assets():
|
||||
print(">", asset)
|
||||
print(" ", asset.name)
|
||||
for artifact in artifacts:
|
||||
aname = str(Path(artifact).name)
|
||||
if asset.name == aname:
|
||||
print(" removing '%s'..." % asset.name)
|
||||
asset.delete_asset()
|
||||
print(" uploading '%s'..." % artifact)
|
||||
gh_release.upload_asset(artifact, name=aname)
|
||||
artifacts.remove(artifact)
|
||||
break
|
||||
if getenv('INPUT_RM', 'false') == 'true':
|
||||
print("· RM set. All previous assets are being cleared...")
|
||||
for asset in gh_release.get_assets():
|
||||
print(" ", asset.name)
|
||||
asset.delete_asset()
|
||||
else:
|
||||
for asset in gh_release.get_assets():
|
||||
print(">", asset)
|
||||
print(" ", asset.name)
|
||||
for artifact in artifacts:
|
||||
aname = str(Path(artifact).name)
|
||||
if asset.name == aname:
|
||||
print(" removing '%s'..." % asset.name)
|
||||
asset.delete_asset()
|
||||
print(" uploading '%s'..." % artifact)
|
||||
gh_release.upload_asset(artifact, name=aname)
|
||||
artifacts.remove(artifact)
|
||||
break
|
||||
|
||||
for artifact in artifacts:
|
||||
print(" uploading '%s'..." % artifact)
|
||||
|
||||
Reference in New Issue
Block a user