Skip to content

Commit 6c24e24

Browse files
vsochjohrstrom
andauthored
Upload new version (#6)
* add the ability to make a new version on an existing doi * add readme updates for specifying a doi * add doi to the the action interface * add debug log * use conceptdoi * one last readme update * more docs about versions * add alt text for png * refactoring deploy.sh to be more organized, also tested to deploy different version * zenodo json not hard requirement Signed-off-by: vsoch <[email protected]> Co-authored-by: Jeff Ohrstrom <[email protected]> Co-authored-by: vsoch <[email protected]>
1 parent 39e810a commit 6c24e24

File tree

5 files changed

+317
-73
lines changed

5 files changed

+317
-73
lines changed

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
zenodo_json: .zenodo.json
2929
archive: ${{ env.archive }}
3030
token: ${{ secrets.ZENODO_TOKEN }}
31+
doi: 10.5281/zenodo.6326822
3132

3233
- name: View Outputs
3334
env:
@@ -50,4 +51,3 @@ jobs:
5051
echo "latest html ${latest_html}"
5152
echo "record ${record}"
5253
echo "record html ${record_html}"
53-

README.md

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,24 @@ I think this is kind of silly, but that's just me.
3737

3838
## Usage
3939

40+
When looking at artifacts in Zenodo you'll see a versions card like the image below. This artifact has
41+
only one version, 0.0.15. By default, this is the behavior of this action - to create brand new artifacts
42+
with only one version.
43+
44+
If, however, you'd like to make new versions you can specify the doi that represents *all*
45+
versions. In this image you would specify `10.5281/zenodo.6326822`. This action will then
46+
create new versions tied to this DOI.
47+
48+
![Zenodo card for versions. '0.0.15' is the only version and a DOI of 10.5281/zenodo.6326823. The footer of the card has a site all versions with DOI 10.5281/zenodo.6326822](img/zenodo_versions.png)
49+
4050
### GitHub Action
4151

42-
After you complete the steps above to create the metadata file, you might create a release
43-
action as follows:
52+
After you complete the steps above to create the metadata file, you have two options.
53+
54+
#### Existing DOI
55+
56+
If you have an existing DOI that is of the **all versions** type meaning we can update it, you should provide it to the action.
57+
The example below shows running a release workflow and providing an archive to update to a new version (**released under the same DOI**)
4458

4559
```yaml
4660
name: Zenodo Release
@@ -68,13 +82,73 @@ jobs:
6882
with:
6983
token: ${{ secrets.ZENODO_TOKEN }}
7084
version: ${{ github.event.release.tag_name }}
71-
zenodo_json: .zenodo.json
85+
zenodo_json: .zenodo.json # optional
7286
archive: ${{ env.archive }}
87+
88+
# Optional DOI for all versions. Leaving this blank (the default) will create
89+
# a new DOI on every release. Use a DOI that represents all versions will
90+
# create a new version for this existing DOI.
91+
#
92+
# Newer versions have their own DOIs, but they're also linked to this DOI
93+
# as a different version. When using this, use the DOI for all versions.
94+
doi: '10.5281/zenodo.6326822'
7395
```
7496
75-
Notice how we are choosing to use the .tar.gz (you could use the zip too at `${{ github.event.release.zipball_url }}`)
76-
and using the default zenodo.json that is obtained from the checked out repository.
97+
Notice how we are choosing to use the .tar.gz (you could use the zip too at `${{ github.event.release.zipball_url }}`).
98+
Note that the "zenodo.json" is optional only if you've already created the record with some metadata. If you provide it,
99+
it will be used to update metadata found with the previous upload. If you don't provide it, the previous upload will
100+
only be updated for the date and version. Note that we are considering adding an ability to upload from new authors found
101+
in the commit history, but this is not implemented yet.
102+
103+
#### New DOI
104+
105+
If you want to be creating fresh DOIs and releases (with no shared DOI for all versions) for each one, just remove the doi variable. Note
106+
that for this case, the .zenodo.json is required as there isn't a previous record to get it from.
107+
108+
```yaml
109+
name: Zenodo Release
110+
111+
on:
112+
release:
113+
types: [published]
114+
115+
jobs:
116+
deploy:
117+
runs-on: ubuntu-20.04
118+
119+
steps:
120+
- uses: actions/checkout@v3
121+
- name: download archive to runner
122+
env:
123+
tarball: ${{ github.event.release.tarball_url }}
124+
run: |
125+
name=$(basename ${tarball})
126+
curl -L $tarball > $name
127+
echo "archive=${name}" >> $GITHUB_ENV
128+
129+
- name: Run Zenodo Deploy
130+
uses: rseng/zenodo-release@main
131+
with:
132+
token: ${{ secrets.ZENODO_TOKEN }}
133+
version: ${{ github.event.release.tag_name }}
134+
zenodo_json: .zenodo.json # required
135+
archive: ${{ env.archive }}
136+
```
137+
138+
#### Archives
139+
140+
For both of the above, instead of an exact archive path you can also use a pattern to give to Python's `glob.glob`. E.g.,:
141+
142+
```yaml
143+
with:
144+
archive: "files/*.tar.gz"
145+
```
146+
147+
Note that we will be testing support for more than one path or pattern soon.
77148
We also grab the version as the release tag. We are also running on the publication of a release.
149+
150+
#### Outputs
151+
78152
If you want to see or do something with the outputs, add an `id` to the deploy step and do:
79153

80154
```yaml
@@ -119,7 +193,7 @@ the following:
119193
```bash
120194
export ZENODO_TOKEN=xxxxxxxxxxxxxxxxxxxx
121195
122-
# archive # identifier # version
123-
$ python scripts/deploy.py upload 0.0.0.tar.gz 6326700 --version 0.0.0
196+
# archive # multi-version DOI # new version
197+
$ python scripts/deploy.py upload 0.0.0.tar.gz --doi 10.5281/zenodo.6326822 --version 0.0.0
124198
```
125199

action.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ inputs:
1212
required: true
1313
zenodo_json:
1414
description: Path to zenodo.json to upload with metadata (must exist)
15+
doi:
16+
descripton: The DOI to create a new version from
1517

1618
outputs:
1719
badge:
@@ -54,5 +56,16 @@ runs:
5456
version: ${{ inputs.version }}
5557
ACTION_PATH: ${{ github.action_path }}
5658
ZENODO_TOKEN: ${{ inputs.token }}
57-
run: python ${{ github.action_path }}/scripts/deploy.py upload ${archive} --zenodo-json ${zenodo_json} --version ${version}
59+
doi: ${{ inputs.doi }}
60+
run: |
61+
command="python ${{ github.action_path }}/scripts/deploy.py upload ${archive} --version ${version}"
62+
if [[ "${doi}" != "" ]]; then
63+
command="$command --doi ${doi}"
64+
fi
65+
if [[ "${zenodo_json}" != "" ]]; then
66+
command="$command --zenodo-json ${zenodo_json}"
67+
fi
68+
printf "$command\n"
69+
$command
70+
5871
shell: bash

img/zenodo_versions.png

18.4 KB
Loading

0 commit comments

Comments
 (0)