Skip to content

Commit

Permalink
Upload new version (#6)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people committed Mar 8, 2022
1 parent 39e810a commit 6c24e24
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
zenodo_json: .zenodo.json
archive: ${{ env.archive }}
token: ${{ secrets.ZENODO_TOKEN }}
doi: 10.5281/zenodo.6326822

- name: View Outputs
env:
Expand All @@ -50,4 +51,3 @@ jobs:
echo "latest html ${latest_html}"
echo "record ${record}"
echo "record html ${record_html}"
88 changes: 81 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,24 @@ I think this is kind of silly, but that's just me.

## Usage

When looking at artifacts in Zenodo you'll see a versions card like the image below. This artifact has
only one version, 0.0.15. By default, this is the behavior of this action - to create brand new artifacts
with only one version.

If, however, you'd like to make new versions you can specify the doi that represents *all*
versions. In this image you would specify `10.5281/zenodo.6326822`. This action will then
create new versions tied to this DOI.

![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)

### GitHub Action

After you complete the steps above to create the metadata file, you might create a release
action as follows:
After you complete the steps above to create the metadata file, you have two options.

#### Existing DOI

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.
The example below shows running a release workflow and providing an archive to update to a new version (**released under the same DOI**)

```yaml
name: Zenodo Release
Expand Down Expand Up @@ -68,13 +82,73 @@ jobs:
with:
token: ${{ secrets.ZENODO_TOKEN }}
version: ${{ github.event.release.tag_name }}
zenodo_json: .zenodo.json
zenodo_json: .zenodo.json # optional
archive: ${{ env.archive }}

# Optional DOI for all versions. Leaving this blank (the default) will create
# a new DOI on every release. Use a DOI that represents all versions will
# create a new version for this existing DOI.
#
# Newer versions have their own DOIs, but they're also linked to this DOI
# as a different version. When using this, use the DOI for all versions.
doi: '10.5281/zenodo.6326822'
```
Notice how we are choosing to use the .tar.gz (you could use the zip too at `${{ github.event.release.zipball_url }}`)
and using the default zenodo.json that is obtained from the checked out repository.
Notice how we are choosing to use the .tar.gz (you could use the zip too at `${{ github.event.release.zipball_url }}`).
Note that the "zenodo.json" is optional only if you've already created the record with some metadata. If you provide it,
it will be used to update metadata found with the previous upload. If you don't provide it, the previous upload will
only be updated for the date and version. Note that we are considering adding an ability to upload from new authors found
in the commit history, but this is not implemented yet.

#### New DOI

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
that for this case, the .zenodo.json is required as there isn't a previous record to get it from.

```yaml
name: Zenodo Release
on:
release:
types: [published]
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: download archive to runner
env:
tarball: ${{ github.event.release.tarball_url }}
run: |
name=$(basename ${tarball})
curl -L $tarball > $name
echo "archive=${name}" >> $GITHUB_ENV
- name: Run Zenodo Deploy
uses: rseng/zenodo-release@main
with:
token: ${{ secrets.ZENODO_TOKEN }}
version: ${{ github.event.release.tag_name }}
zenodo_json: .zenodo.json # required
archive: ${{ env.archive }}
```

#### Archives

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.,:

```yaml
with:
archive: "files/*.tar.gz"
```

Note that we will be testing support for more than one path or pattern soon.
We also grab the version as the release tag. We are also running on the publication of a release.

#### Outputs

If you want to see or do something with the outputs, add an `id` to the deploy step and do:

```yaml
Expand Down Expand Up @@ -119,7 +193,7 @@ the following:
```bash
export ZENODO_TOKEN=xxxxxxxxxxxxxxxxxxxx
# archive # identifier # version
$ python scripts/deploy.py upload 0.0.0.tar.gz 6326700 --version 0.0.0
# archive # multi-version DOI # new version
$ python scripts/deploy.py upload 0.0.0.tar.gz --doi 10.5281/zenodo.6326822 --version 0.0.0
```

15 changes: 14 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ inputs:
required: true
zenodo_json:
description: Path to zenodo.json to upload with metadata (must exist)
doi:
descripton: The DOI to create a new version from

outputs:
badge:
Expand Down Expand Up @@ -54,5 +56,16 @@ runs:
version: ${{ inputs.version }}
ACTION_PATH: ${{ github.action_path }}
ZENODO_TOKEN: ${{ inputs.token }}
run: python ${{ github.action_path }}/scripts/deploy.py upload ${archive} --zenodo-json ${zenodo_json} --version ${version}
doi: ${{ inputs.doi }}
run: |
command="python ${{ github.action_path }}/scripts/deploy.py upload ${archive} --version ${version}"
if [[ "${doi}" != "" ]]; then
command="$command --doi ${doi}"
fi
if [[ "${zenodo_json}" != "" ]]; then
command="$command --zenodo-json ${zenodo_json}"
fi
printf "$command\n"
$command
shell: bash
Binary file added img/zenodo_versions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6c24e24

Please sign in to comment.