zenodo upload with CLI zenodraft

master v0.7.0
Martin Scheidt 2022-04-05 14:28:09 +02:00
parent bdf679986e
commit 0b1a14fbc9
9 changed files with 204 additions and 120 deletions

View File

@ -59,7 +59,6 @@ jobs:
# download artifact in folder artifact/
- uses: actions/download-artifact@v3
- run: cd artifact
# - name: "install ghostscript"
# run: sudo apt-get install -y ghostscript
@ -108,6 +107,9 @@ jobs:
## opening a debug console
- name: Setup upterm session
env:
# ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }}
ZENODO_SANDBOX_ACCESS_TOKEN: ${{ secrets.ZENODO_SANDBOX_ACCESS_TOKEN }}
uses: lhotari/action-upterm@v1
with:
limit-access-to-actor: true

View File

@ -13,13 +13,23 @@ on:
jobs:
create_package:
name: "create a TeX Live package for tikz-trackschematic"
outputs:
version: ${{ steps.tag.outputs.tag }}
runs-on: ubuntu-latest
steps:
# 1. checkout the repo
# 1. get varibale tag and put it in ${{ steps.tag.outputs.tag }}
- name: "get tag"
id: tag
uses: dawidd6/action-get-tag@v1
with:
# Optionally strip `v` prefix
strip_v: false
# 2. checkout the repo
- name: "checkout"
uses: actions/checkout@v2
# 2. install TeX Live
# 3. install TeX Live
- name: "install ghostscript"
run: sudo apt-get install -y ghostscript
@ -29,18 +39,10 @@ jobs:
profile-path: ${{ github.workspace }}/.github/tex/profile.minimal.txt
packages-path: ${{ github.workspace }}/.github/tex/packages.doc.txt
# 3. (re-)compile the documentation
# 4. (re-)compile the documentation
- name: "update tikz-trackschematic documentation before release"
run: ./build.sh --non-interactive --memory-increase --compile-doc
# 4. get varibale ${{ steps.tag.outputs.tag }}
- name: "get tag"
id: tag
uses: dawidd6/action-get-tag@v1
with:
# Optionally strip `v` prefix
strip_v: false
# 5. create package and release notes
- name: "create tikz-trackschematic package"
run: ./build.sh --non-interactive --release ${{ steps.tag.outputs.tag }}
@ -48,23 +50,18 @@ jobs:
# 6. upload artifact to share it with other jobs
- uses: actions/upload-artifact@v3
with:
path: tikz-trackschematic-${{ steps.tag.outputs.tag }}.zip
path: |
tikz-trackschematic-${{ steps.tag.outputs.tag }}.zip
release-note-${{ steps.tag.outputs.tag }}.md
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
- uses: actions/upload-artifact@v3
with:
path: release-note-${{ steps.tag.outputs.tag }}.md
if-no-files-found: warn # 'error' or 'ignore' are also available, defaults to `warn`
- uses: actions/upload-artifact@v3
with:
path: .github/tex/tikz-trackschematic.pkg
if-no-files-found: warn # 'error' or 'ignore' are also available, defaults to `warn`
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
- uses: actions/upload-artifact@v3
with:
path: .github/zenodo/metadata.json
if-no-files-found: warn # 'error' or 'ignore' are also available, defaults to `warn`
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
publish_github:
needs: create_package
@ -74,15 +71,7 @@ jobs:
# 1. download artifact in folder artifact/
- uses: actions/download-artifact@v3
# 2. get varibale ${{ steps.tag.outputs.tag }}
- name: "get tag"
id: tag
uses: dawidd6/action-get-tag@v1
with:
# Optionally strip `v` prefix
strip_v: false
# 3. publish package as new release on github
# 2. creating a new release
- name: "create release"
id: create_release
uses: actions/create-release@v1
@ -91,20 +80,22 @@ jobs:
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: artifact/release-note-${{ steps.tag.outputs.tag }}.md
body_path: artifact/release-note-${{needs.create_package.outputs.version}}.md
draft: false
prerelease: false
# 3. upload package to new release
- name: "upload release asset"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifact/tikz-trackschematic-${{ steps.tag.outputs.tag }}.zip
asset_name: tikz-trackschematic-${{ steps.tag.outputs.tag }}.zip
asset_path: artifact/tikz-trackschematic-${{needs.create_package.outputs.version}}.zip
asset_name: tikz-trackschematic-${{needs.create_package.outputs.version}}.zip
asset_content_type: application/zip
# 4. publish release on github
- name: "publish release"
uses: StuYarrow/publish-release@v1
env:
@ -117,11 +108,10 @@ jobs:
name: "publish on CTAN"
runs-on: ubuntu-latest
steps:
# 1. download artifact in folder artifact/
# 1. download artifact in folder artifact/ and move it one level up
- uses: actions/download-artifact@v3
- run: |
mv ./artifact/tikz-trackschematic-*.zip ./
mv ./artifact/tikz-trackschematic.pkg ./
# 2. install ctan-o-mat
- name: "setup TeX Live (via paolobrasolin)"
@ -132,43 +122,54 @@ jobs:
# 3. upload new release to CTAN
- name: CTAN submit
run: ctan-o-mat --verbose --submit tikz-trackschematic.pkg
run: ctan-o-mat --verbose --submit artifact/tikz-trackschematic.pkg
publish_zenodo:
needs: create_package
name: "publish on zenodo sandbox"
name: "publish on zenodo"
outputs:
doi: ${{ steps.zenodraft.outputs.doi }}
runs-on: ubuntu-latest
steps:
# 1. get varibale ${{ steps.tag.outputs.tag }}
- name: "get tag"
id: tag
uses: dawidd6/action-get-tag@v1
with:
# Optionally strip `v` prefix
strip_v: false
# 2. checkout the repo for zenodraft/action@0.10.0 to work
- name: "checkout"
uses: actions/checkout@v2
# 3. download artifact in folder artifact/ and move it one level up
# 1. download artifact in folder artifact/ and move it one level up
- uses: actions/download-artifact@v3
- run: |
mv ./artifact/tikz-trackschematic-*.zip ./
mv ./artifact/metadata.json ./
# 4. upload to zenodo
- name: "uploading to zenodo sandbox"
# 2. install zenodraft
- name: "install zenodraft"
run: npm install -g zenodraft
# 3. upload new release to zenodo
- name: "uploading to zenodo"
id: zenodraft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }}
uses: zenodraft/action@0.10.0
COLLECTION: 5539844
run: |
ID=$(zenodraft deposition create in-existing-collection $COLLECTION)
zenodraft file add $ID tikz-trackschematic-*.zip
zenodraft metadata update $ID artifact/metadata.json
zenodraft deposition publish $ID
echo "::set-output name=doi::$(zenodraft deposition show prereserved $ID)"
update_citation:
needs: publish_zenodo
name: "updates CITATION.cff"
runs-on: ubuntu-latest
steps:
# 1. checkout the repo for zenodraft/action@0.10.0 to work
- name: "checkout"
uses: actions/checkout@v2
- run: ./build.sh --update-cite ${{needs.publish_zenodo.outputs.doi}}
- name: push
uses: github-actions-x/commit@v2.8
with:
collection: 5539844
filenames: tikz-trackschematic-${{ steps.tag.outputs.tag }}.zip
upsert-doi: true
upsert-location: identifiers[1]
metadata: metadata.json
publish: true
sandbox: false
verbose: true
github-token: ${{ secrets.GITHUB_TOKEN }}
push-branch: 'master'
force-add: 'true'
files: CITATION.cff
commit-message: 'updated DOI (via github action)'
rebase: 'true' # pull and rebase before commit

View File

@ -32,7 +32,7 @@ jobs:
- name: "setup TeX Live (via paolobrasolin)"
uses: paolobrasolin/setup-texlive-action@v1
with:
profile-path: ${{ github.workspace }}/.github/tex/profile.minimal.txt
profile-path: ${{ github.workspace }}/.github/tex/profile.basic.txt
packages-path: ${{ github.workspace }}/.github/tex/packages.test.txt
- name: "test tikz-trackschematic"

View File

@ -11,65 +11,116 @@ on:
jobs:
create_package:
name: "create a TeX Live package"
outputs:
version: ${{ steps.tag.outputs.tag }}
runs-on: ubuntu-latest
steps:
# set varibale ${{ steps.tag.outputs.tag }}
- name: "get tag"
id: tag
run: echo "::set-output name=tag::v0.7.0"
# checkout the repo
- name: "checkout"
uses: actions/checkout@v2
# create package and release notes
- name: "create tikz-trackschematic package"
run: ./build.sh --non-interactive --release v0.7.0
run: ./build.sh --non-interactive --release ${{ steps.tag.outputs.tag }}
# upload artifact to share it with other jobs
- uses: actions/upload-artifact@v3
with:
path: tikz-trackschematic-v0.7.0.zip
path: |
tikz-trackschematic-${{ steps.tag.outputs.tag }}.zip
release-note-${{ steps.tag.outputs.tag }}.md
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
- uses: actions/upload-artifact@v3
with:
path: release-note-v0.7.0.md
if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn`
- uses: actions/upload-artifact@v3
with:
path: .github/tex/tikz-trackschematic.pkg
if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn`
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
- uses: actions/upload-artifact@v3
with:
path: .github/zenodo/metadata.json
if-no-files-found: warn # 'warn' or 'ignore' are also available, defaults to `warn`
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
# publish_zenodo:
# needs: create_package
# name: "publish on zenodo sandbox"
# runs-on: ubuntu-latest
# steps:
# # checkout the repo
# - name: "checkout"
# uses: actions/checkout@v2
# # download artifact in folder artifact/
# - uses: actions/download-artifact@v3
# - run: |
# mv ./artifact/tikz-trackschematic-*.zip ./
# mv ./artifact/metadata.json ./
# - name: "uploading to zenodo sandbox"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# # ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }}
# ZENODO_SANDBOX_ACCESS_TOKEN: ${{ secrets.ZENODO_SANDBOX_ACCESS_TOKEN }}
# uses: zenodraft/action@0.10.0
# with:
# # collection: 5539844
# collection: 1047380
# filenames: tikz-trackschematic-v0.7.0.zip
# upsert-doi: true
# upsert-location: identifiers[1]
# metadata: metadata.json
# publish: true
# sandbox: true
# verbose: true
publish_zenodo:
needs: create_package
name: "publish on zenodo sandbox"
outputs:
doi: ${{ steps.zenodraft.outputs.doi }}
runs-on: ubuntu-latest
steps:
# checkout the repo
- name: "checkout"
uses: actions/checkout@v2
# download artifact in folder artifact/
- uses: actions/download-artifact@v3
- run: |
mv ./artifact/tikz-trackschematic-*.zip ./
mv ./artifact/metadata.json ./
mv ./artifact/tikz-trackschematic-${{needs.create_package.outputs.version}}.zip ./
- name: "install zenodraft"
run: npm install -g zenodraft
- name: "uploading to zenodo sandbox"
id: zenodraft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }}
ZENODO_SANDBOX_ACCESS_TOKEN: ${{ secrets.ZENODO_SANDBOX_ACCESS_TOKEN }}
uses: zenodraft/action@0.10.0
COLLECTION: 1047380
run: |
ID=$(zenodraft --sandbox deposition create in-existing-collection $COLLECTION)
zenodraft --sandbox file add $ID tikz-trackschematic-*.zip
zenodraft --sandbox metadata update $ID artifact/metadata.json
zenodraft --sandbox deposition publish $ID
echo "::set-output name=doi::$(zenodraft --sandbox deposition show prereserved $ID)"
update_citation:
needs: publish_zenodo
name: "updates CITATION.cff"
runs-on: ubuntu-latest
steps:
# 1. checkout the repo for zenodraft/action@0.10.0 to work
- name: "checkout"
uses: actions/checkout@v2
- run: ./build.sh --update-cite ${{needs.publish_zenodo.outputs.doi}}
- name: push
uses: github-actions-x/commit@v2.8
with:
# collection: 5539844
collection: 1047380
filenames: tikz-trackschematic-v0.7.0.zip
upsert-doi: true
upsert-location: identifiers[1]
metadata: metadata.json
publish: true
sandbox: true
verbose: true
github-token: ${{ secrets.GITHUB_TOKEN }}
push-branch: 'github-action'
force-add: 'true'
files: CITATION.cff
commit-message: 'updated DOI (via github action)'
name: Martin Scheidt
email: m.scheidt@tu-bs.de

View File

@ -1,6 +1,7 @@
{
"title": "TikZ-trackschematic",
"version": "%%[SCRIPT]",
"version": "%%[SCRIPT]",
"publication_date": "%%[SCRIPT]",
"creators": [
{
"orcid": "0000-0002-9384-8945",

1
.gitignore vendored
View File

@ -277,5 +277,6 @@ Temporary Items
.apdisk
# Archives for upload
artifact
tikz-trackschematic-*.zip
release-note-*.md

View File

@ -40,5 +40,5 @@ keywords:
- tracks
- schematics
license: ISC
version: v0.7.0
date-released: '2022-04-02'
version: v0.6.3
date-released: 2022-02-15

View File

@ -21,7 +21,6 @@ Please note we have a code of conduct, please follow it in all your interactions
3. The versioning scheme we use is [SemVer](http://semver.org/). Increase the version numbers in the following files to the new version that this Pull Request would represent:
1. CHANGELOG.md
2. doc/versionhistory.tex
3. CITATION.cff
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.
5. The following versioning steps will be taken care of by the maintainer:

View File

@ -48,6 +48,8 @@ install, test or release a package for tikz-trackschematic
-r, --release VERSION Creates a .zip with the release for given VERSION in
Semantic Versioning with leading 'v', e.g: v1.0.0
-z, --update-cite DOI Updates the CITATION.cff with the current version in
CHANGELOG.md and a given DOI
EOF
}
@ -60,6 +62,7 @@ TESTING=0 # set by cli argument
COMPILE=0 # set by cli argument
SYMBOLOGY=0 # set by cli argument
RELEASE=0 # set by cli argument
CITATION=0 # set by cli argument
CLEANUP=1 # set by cli argument
process_arguments() {
@ -114,6 +117,15 @@ process_arguments() {
fi
VERSION_STR=$1
;;
-z|--update-cite)
CITATION=1
shift
if [ -z "$1" ] || [ "`echo $1 | cut -c1-1`" = "-" ]; then
print_usage
exit 1
fi
DOI=$1
;;
*)
print_usage
exit 1
@ -453,20 +465,6 @@ check_changelog() {
exit 1
}
check_citation() {
# check if $VERSION is present in CITATION.cff
STATUS=0
grep -qs "version: $VERSION_STR" CITATION.cff || STATUS=1
if [ $STATUS = 0 ]; then
log_note "Version $VERSION_STR is present in CITATION.cff."
return 0
fi
log_error "Version $VERSION_STR not found in CITATION.cff. \
Be sure to edit CITATION.cff and specify current version!"
exit 1
}
check_date() {
## extract DATE from versionhistory.tex, CHANGELOG.md, and CITATION.cff
# fallback: DATE=$(date "+%Y-%m-%d")
@ -475,17 +473,17 @@ check_date() {
#
LINE_1=$(grep "vhEntry{$VERSION_NUM" doc/versionhistory.tex)
LINE_2=$(grep "Version \[$VERSION_NUM\]" CHANGELOG.md)
LINE_3=$(grep "date-released:" CITATION.cff)
# LINE_3=$(grep "date-released:" CITATION.cff)
DATEISO_1=$(echo $LINE_1 | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])')
DATEISO_2=$(echo $LINE_2 | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])')
DATEISO_3=$(echo $LINE_3 | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])')
# DATEISO_3=$(echo $LINE_3 | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])')
if [ $DATEISO_1 != $DATEISO_2 ]; then
STATUS=1
fi
if [ $DATEISO_1 != $DATEISO_3 ]; then
STATUS=1
fi
# if [ $DATEISO_1 != $DATEISO_3 ]; then
# STATUS=1
# fi
if [ $STATUS = 0 ]; then
DATE="$DATEISO_1"
@ -623,7 +621,7 @@ create_zenodo_metadata() {
sed -i".backup" -e"s/\"version\": \"%%\[SCRIPT\]\"/\"version\": \"$VERSION_STR\"/g" .github/zenodo/metadata.json
# 2. replace "publication_date": "%%[SCRIPT]"
# sedi "s/\"publication_date\": \"%%\[SCRIPT\]\"/\"publication_date\": \"$DATE\"/g" .github/zenodo/metadata.json
sedi "s/\"publication_date\": \"%%\[SCRIPT\]\"/\"publication_date\": \"$DATE\"/g" .github/zenodo/metadata.json
}
run_compile_documentation() {
@ -953,6 +951,33 @@ change_tex_memory() {
fi
}
update_citation() {
## use CHANGELOG.md as source for $VERSION and $DATE
CHANGELOG_LINE=$(grep "Version \[" CHANGELOG.md | awk "NR==1")
VERSION=$(echo $CHANGELOG_LINE | egrep -o '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)?')
DATE=$(echo $CHANGELOG_LINE | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])')
## check for already made changes
STATUS=0
grep -qs "version: v$VERSION" CITATION.cff || STATUS=1
if [ $STATUS = 0 ]; then
log_note "CITATION.cff is already up to date!"
return 0
fi
## find lines in CITATION.cff
VERSION_LINE=$(grep -n 'version: v' CITATION.cff | cut -d: -f1)
DATE_LINE=$(grep -n 'date-released:' CITATION.cff | cut -d: -f1)
# select the second DOI
DOI_LINE=$(grep -n 'type: doi' CITATION.cff | cut -d: -f1 | awk "NR==2")
DOI_LINE=$(( $DOI_LINE + 1 ))
## update CITATION.cff
sedi "${VERSION_LINE}s|.*|version: v${VERSION}|" CITATION.cff
sedi "${DATE_LINE}s|.*|date-released: ${DATE}|" CITATION.cff
sedi "${DOI_LINE}s|.*| value: ${DOI}|" CITATION.cff
}
cleanup() {
## -- cleanup
## from create_release
@ -1080,7 +1105,6 @@ if [ $RELEASE = 1 ]; then
check_changelog
check_changelog_url1
check_changelog_url2
check_citation
check_date
## check for installed software
@ -1093,6 +1117,11 @@ if [ $RELEASE = 1 ]; then
create_zenodo_metadata
fi
if [ $CITATION = 1 ]; then
##
update_citation
fi
##
cleanup
##