Skip to content

Commit 3530a92

Browse files
committed
making release action work part 2
1 parent 4b7c88f commit 3530a92

File tree

1 file changed

+122
-123
lines changed

1 file changed

+122
-123
lines changed

.github/workflows/release.yaml

Lines changed: 122 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ jobs:
149149
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
150150
echo "new=$VERSION" >> $GITHUB_OUTPUT
151151
152-
# 3. create release archive
153152
## exclude certain files from release archive
154153
- name: "check files"
155154
id: file_check
@@ -270,133 +269,133 @@ jobs:
270269
with:
271270
id: ${{ steps.create_release.outputs.id }}
272271

273-
# zenodo:
274-
# needs: [create_package, version]
275-
# name: "publish on zenodo"
276-
# outputs:
277-
# doi: ${{ steps.zenodraft.outputs.doi }}
278-
# runs-on: ubuntu-latest
279-
# steps:
280-
# - run: echo "Archiving package on zenodo to get a DOI:" >> $GITHUB_STEP_SUMMARY
281-
# # 1. download artifact in folder artifact/ and move it one level up and checkout the repo
282-
# - uses: actions/checkout@v3
283-
# - uses: actions/download-artifact@v3
284-
# - run: |
285-
# mv ../artifact/${{ env.REPO_NAME }}-v${{ needs.version.outputs.new }}.zip ../
286-
# echo "- getting ZIP-Archive and release notes :white_check_mark:" >> $GITHUB_STEP_SUMMARY
272+
zenodo:
273+
needs: [create_package, version]
274+
name: "publish on zenodo"
275+
outputs:
276+
doi: ${{ steps.zenodraft.outputs.doi }}
277+
runs-on: ubuntu-latest
278+
steps:
279+
- run: echo "Archiving package on zenodo to get a DOI:" >> $GITHUB_STEP_SUMMARY
280+
# 1. download artifact in folder artifact/ and move it one level up and checkout the repo
281+
- uses: actions/checkout@v3
282+
- uses: actions/download-artifact@v3
283+
- run: |
284+
mv artifact/${{ env.REPO_NAME }}-v${{ needs.version.outputs.new }}.zip ../
285+
echo "- getting ZIP-Archive and release notes :white_check_mark:" >> $GITHUB_STEP_SUMMARY
287286
288-
# # 2. install zenodraft
289-
# - name: "install zenodraft"
290-
# env:
291-
# URL: "https://zenodo.org/"
292-
# run: |
293-
# STATUS=0
294-
# npm install -g zenodraft
295-
# echo "- installing zenodraft :white_check_mark:" >> $GITHUB_STEP_SUMMARY
296-
# if ! curl --output /dev/null --silent --head --fail "$URL"; then
297-
# STATUS=1
298-
# fi
299-
# if [ $STATUS = 1 ]; then
300-
# echo "- :no_entry_sign: $URL is not reachable" >> $GITHUB_STEP_SUMMARY
301-
# echo ":warning: Please re-run action later!" >> $GITHUB_STEP_SUMMARY
302-
# echo ":warning: Please remove github release manually!" >> $GITHUB_STEP_SUMMARY
303-
# exit 1
304-
# else
305-
# echo "- $URL is reachable :white_check_mark:" >> $GITHUB_STEP_SUMMARY
306-
# fi
287+
# 2. install zenodraft
288+
- name: "install zenodraft"
289+
env:
290+
URL: "https://zenodo.org/"
291+
run: |
292+
STATUS=0
293+
npm install -g zenodraft
294+
echo "- installing zenodraft :white_check_mark:" >> $GITHUB_STEP_SUMMARY
295+
if ! curl --output /dev/null --silent --head --fail "$URL"; then
296+
STATUS=1
297+
fi
298+
if [ $STATUS = 1 ]; then
299+
echo "- :no_entry_sign: $URL is not reachable" >> $GITHUB_STEP_SUMMARY
300+
echo ":warning: Please re-run action later!" >> $GITHUB_STEP_SUMMARY
301+
echo ":warning: Please remove github release manually!" >> $GITHUB_STEP_SUMMARY
302+
exit 1
303+
else
304+
echo "- $URL is reachable :white_check_mark:" >> $GITHUB_STEP_SUMMARY
305+
fi
307306
308-
# # 3. Update zenodo metadata.json
309-
# - name: "Update zenodo metadata.json"
310-
# run: |
311-
# VERSION=${{ needs.version.outputs.new }}
312-
# sed -i".backup" -e"s/\"version\": \"%%\[SCRIPT\]\"/\"version\": \"$VERSION\"/g" .github/zenodo/metadata.json
313-
# echo "- updating zenodo metadata :white_check_mark:" >> $GITHUB_STEP_SUMMARY
307+
# 3. Update zenodo metadata.json
308+
- name: "Update zenodo metadata.json"
309+
run: |
310+
VERSION=${{ needs.version.outputs.new }}
311+
sed -i".backup" -e"s/\"version\": \"%%\[SCRIPT\]\"/\"version\": \"$VERSION\"/g" .github/zenodo/metadata.json
312+
echo "- updating zenodo metadata :white_check_mark:" >> $GITHUB_STEP_SUMMARY
314313
315-
# # 4. upload new release to zenodo
316-
# - name: "uploading to zenodo"
317-
# id: zenodraft
318-
# env:
319-
# ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }}
320-
# run: |
321-
# DOI=$(zenodraft deposition create version ${{ env.ZENODO_COLLECTION }})
322-
# zenodraft file add $DOI ${{ env.REPO_NAME }}-v*.zip
323-
# zenodraft metadata update $DOI .github/zenodo/metadata.json
324-
# zenodraft deposition publish $DOI
325-
# ## =================================
326-
# ## provide variables for subsequent jobs
327-
# ## ---------------------------------
328-
# echo "doi=10.5281/zenodo.$DOI" >> $GITHUB_OUTPUT
329-
# echo "- publish release at zenodo with DOI: 10.5281/zenodo.$DOI :white_check_mark:" >> $GITHUB_STEP_SUMMARY
314+
# 4. upload new release to zenodo
315+
- name: "uploading to zenodo"
316+
id: zenodraft
317+
env:
318+
ZENODO_ACCESS_TOKEN: ${{ secrets.ZENODO_ACCESS_TOKEN }}
319+
run: |
320+
DOI=$(zenodraft deposition create version ${{ env.ZENODO_COLLECTION }})
321+
zenodraft file add $DOI ${{ env.REPO_NAME }}-v*.zip
322+
zenodraft metadata update $DOI .github/zenodo/metadata.json
323+
zenodraft deposition publish $DOI
324+
## =================================
325+
## provide variables for subsequent jobs
326+
## ---------------------------------
327+
echo "doi=10.5281/zenodo.$DOI" >> $GITHUB_OUTPUT
328+
echo "- publish release at zenodo with DOI: 10.5281/zenodo.$DOI :white_check_mark:" >> $GITHUB_STEP_SUMMARY
330329
331-
# update_repository:
332-
# needs: [zenodo, version]
333-
# name: "updating CITATION.cff and CHANGELOG.md"
334-
# runs-on: ubuntu-latest
335-
# steps:
336-
# - run: echo "Updating CITATION.cff and CHANGELOG.md:" >> $GITHUB_STEP_SUMMARY
337-
# # 1. checkout the repo
338-
# - name: "checkout"
339-
# uses: actions/checkout@v3
340-
# # with:
341-
# # ref: main
330+
update_repository:
331+
needs: [zenodo, version]
332+
name: "updating CITATION.cff and CHANGELOG.md"
333+
runs-on: ubuntu-latest
334+
steps:
335+
- run: echo "Updating CITATION.cff and CHANGELOG.md:" >> $GITHUB_STEP_SUMMARY
336+
# 1. checkout the repo
337+
- name: "checkout"
338+
uses: actions/checkout@v3
339+
# with:
340+
# ref: main
342341

343-
# # 2. update CITATION.cff
344-
# - name: "update CITATION.cff"
345-
# run: |
346-
# DATE=$(date "+%Y-%m-%d")
347-
# VERSION=${{ needs.version.outputs.new }}
348-
# DOI=${{ needs.publish_zenodo.outputs.doi }}
349-
# echo "find lines in CITATION.cff"
350-
# VERSION_LINE=$(grep -n '^version:' CITATION.cff | cut -d: -f1)
351-
# DATE_LINE=$(grep -n '^date-released:' CITATION.cff | cut -d: -f1)
352-
# echo "select the second DOI"
353-
# DOI_LINE=$(grep -n 'type: doi' CITATION.cff | cut -d: -f1 | awk "NR==2")
354-
# DOI_LINE=$(( $DOI_LINE + 1 ))
355-
# echo "update CITATION.cff"
356-
# sed -i -- "${VERSION_LINE}s|.*|version: $VERSION|" CITATION.cff
357-
# sed -i -- "${DATE_LINE}s|.*|date-released: ${DATE}|" CITATION.cff
358-
# sed -i -- "${DOI_LINE}s|.*| value: $DOI|" CITATION.cff
359-
# echo "- updated CITATION.cff :white_check_mark:" >> $GITHUB_STEP_SUMMARY
342+
# 2. update CITATION.cff
343+
- name: "update CITATION.cff"
344+
run: |
345+
DATE=$(date "+%Y-%m-%d")
346+
VERSION=${{ needs.version.outputs.new }}
347+
DOI=${{ needs.publish_zenodo.outputs.doi }}
348+
echo "find lines in CITATION.cff"
349+
VERSION_LINE=$(grep -n '^version:' CITATION.cff | cut -d: -f1)
350+
DATE_LINE=$(grep -n '^date-released:' CITATION.cff | cut -d: -f1)
351+
echo "select the second DOI"
352+
DOI_LINE=$(grep -n 'type: doi' CITATION.cff | cut -d: -f1 | awk "NR==2")
353+
DOI_LINE=$(( $DOI_LINE + 1 ))
354+
echo "update CITATION.cff"
355+
sed -i -- "${VERSION_LINE}s|.*|version: $VERSION|" CITATION.cff
356+
sed -i -- "${DATE_LINE}s|.*|date-released: ${DATE}|" CITATION.cff
357+
sed -i -- "${DOI_LINE}s|.*| value: $DOI|" CITATION.cff
358+
echo "- updated CITATION.cff :white_check_mark:" >> $GITHUB_STEP_SUMMARY
360359
361-
# # 3. update CHANGELOG.md
362-
# - name: "update CHANGELOG.md"
363-
# run: |
364-
# DATE=$(date "+%Y-%m-%d")
365-
# VERSION=${{ needs.version.outputs.new }}
366-
# URL="https://github.com/${{ env.ACCOUNT_NAME }}/${{ env.REPO_NAME }}"
367-
# CURRENT_VERSION=${{ needs.version.outputs.current }}
368-
# if [[ ${{ env.VERSION_SCHEMA }} = "semantic" ]]; then
369-
# sed -i -- "/## \[Unreleased\]/a\\\n\n## Version [$VERSION] $DATE" CHANGELOG.md
370-
# elif [[ ${{ env.VERSION_SCHEMA }} = "calendar" ]]; then
371-
# sed -i -- "/## \[Unreleased\]/a\\\n\n## Version [$VERSION]" CHANGELOG.md
372-
# fi
373-
# if [ "$CURRENT_VERSION" = "no_version" ]; then
374-
# sed -i -- "s|^\[Unreleased\]: .*$|\[Unreleased\]: $URL/compare/v$VERSION...main\n\[$VERSION\]: $URL/releases/tag/v$VERSION|" CHANGELOG.md
375-
# else
376-
# sed -i -- "s|^\[Unreleased\]: .*$|\[Unreleased\]: $URL/compare/v$VERSION...main\n\[$VERSION\]: $URL/compare/v$CURRENT_VERSION...v$VERSION|" CHANGELOG.md
377-
# fi
378-
# echo "- updated CHANGELOG.md :white_check_mark:" >> $GITHUB_STEP_SUMMARY
360+
# 3. update CHANGELOG.md
361+
- name: "update CHANGELOG.md"
362+
run: |
363+
DATE=$(date "+%Y-%m-%d")
364+
VERSION=${{ needs.version.outputs.new }}
365+
URL="https://github.com/${{ env.ACCOUNT_NAME }}/${{ env.REPO_NAME }}"
366+
CURRENT_VERSION=${{ needs.version.outputs.current }}
367+
if [[ ${{ env.VERSION_SCHEMA }} = "semantic" ]]; then
368+
sed -i -- "/## \[Unreleased\]/a\\\n\n## Version [$VERSION] $DATE" CHANGELOG.md
369+
elif [[ ${{ env.VERSION_SCHEMA }} = "calendar" ]]; then
370+
sed -i -- "/## \[Unreleased\]/a\\\n\n## Version [$VERSION]" CHANGELOG.md
371+
fi
372+
if [ "$CURRENT_VERSION" = "no_version" ]; then
373+
sed -i -- "s|^\[Unreleased\]: .*$|\[Unreleased\]: $URL/compare/v$VERSION...main\n\[$VERSION\]: $URL/releases/tag/v$VERSION|" CHANGELOG.md
374+
else
375+
sed -i -- "s|^\[Unreleased\]: .*$|\[Unreleased\]: $URL/compare/v$VERSION...main\n\[$VERSION\]: $URL/compare/v$CURRENT_VERSION...v$VERSION|" CHANGELOG.md
376+
fi
377+
echo "- updated CHANGELOG.md :white_check_mark:" >> $GITHUB_STEP_SUMMARY
379378
380-
# # 4. push the change back to main
381-
# - name: push
382-
# uses: EndBug/add-and-commit@v9
383-
# with:
384-
# message: "updated to ${{ needs.version.outputs.new }} (via github action)"
385-
# add: CITATION.cff CHANGELOG.md
386-
# author_name: ${{ env.ACCOUNT_NAME }}
387-
# author_email: railedukit@ownx.net
388-
# tag: 'v${{ needs.version.outputs.new }} --force'
389-
# - run: echo "- updated repository with new CITATION.cff and CHANGELOG.md :white_check_mark:" >> $GITHUB_STEP_SUMMARY
379+
# 4. push the change back to main
380+
- name: push
381+
uses: EndBug/add-and-commit@v9
382+
with:
383+
message: "updated to ${{ needs.version.outputs.new }} (via github action)"
384+
add: CITATION.cff CHANGELOG.md
385+
author_name: ${{ env.ACCOUNT_NAME }}
386+
author_email: railedukit@ownx.net
387+
tag: 'v${{ needs.version.outputs.new }} --force'
388+
- run: echo "- updated repository with new CITATION.cff and CHANGELOG.md :white_check_mark:" >> $GITHUB_STEP_SUMMARY
390389

391-
# publish_mastodon:
392-
# needs: [zenodo, version]
393-
# name: "Toot about it on ${{ env.MASTODON_INSTANCE }}"
394-
# runs-on: ubuntu-latest
395-
# steps:
396-
# - uses: cbrgm/mastodon-github-action@v1
397-
# with:
398-
# message: "The new version ${{ needs.version.outputs.new }} of ${{ env.REPO_NAME }} is available! DOI: https://doi.org/${{ needs.zenodo.outputs.doi }}."
399-
# visibility: "public" # default: public
400-
# env:
401-
# MASTODON_URL: "https://${{ env.MASTODON_INSTANCE }}/"
402-
# MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} # access token
390+
publish_mastodon:
391+
needs: [zenodo, version]
392+
name: "Toot about it on $MASTODON_INSTANCE"
393+
runs-on: ubuntu-latest
394+
steps:
395+
- uses: cbrgm/mastodon-github-action@v1
396+
with:
397+
message: "The new version ${{ needs.version.outputs.new }} of ${{ env.REPO_NAME }} is available! DOI: https://doi.org/${{ needs.zenodo.outputs.doi }}."
398+
visibility: "public" # default: public
399+
env:
400+
MASTODON_URL: "https://${{ env.MASTODON_INSTANCE }}/"
401+
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} # access token

0 commit comments

Comments
 (0)