IGA
IGA is the InvenioRDM GitHub Archiver, a standalone program as well as a GitHub Actions workflow that lets you automatically archive GitHub software releases in an InvenioRDM repository.
Table of contents
Introduction
InvenioRDM is the basis for many institutional repositories such as CaltechDATA that enable users to preserve software and data sets in long-term archive. Though such repositories are critical resources, creating detailed records and uploading assets can be a tedious and error-prone process if done manually. This is where the InvenioRDM GitHub Archiver (IGA) comes in.
IGA creates metadata records and sends releases from GitHub to an InvenioRDM-based repository server. IGA can be invoked from the command line; it also can be set up as a GitHub Actions workflow to archive GitHub releases automatically for a repository each time they are made.
➜
IGA offers many notable features:
- Automatic metadata extraction from GitHub plus
codemeta.json and CITATION.cff files
- Thorough coverage of InvenioRDM record metadata using painstaking procedures
- Recognition of identifiers in CodeMeta & CFF files: ORCID, DOI, PMCID, and more
- Automatic lookup of publication data in DOI.org, PubMed, Google, and other sources
- Automatic lookup of organization names in ROR (assuming ROR id's are provided)
- Automatic lookup of human names in ORCID.org (assuming ORCID id's are provided)
- Automatic splitting of human names into family & given names using ML methods
- Support for InvenioRDM communities
- Support for overriding the record that IGA creates, for complete control if you need it
- Support for using the GitHub API without a GitHub access token in simple cases
- Extensive use of logging so you can see what's going on under the hood
The IGA GitHub action workflow automatically will add the archived DOI to a CodeMeta file and create/update a CFF file using the CodeMeta2CFF workflow.
Installation
IGA can be installed as either (or both) a command-line program on your computer or a GitHub Action in a GitHub repository.
IGA as a standalone program
Please choose an approach that suits your situation and preferences.
Alternative 1: using pipx
Pipx lets you install Python programs in a way that isolates Python dependencies from other Python programs on your system, and yet the resulting iga command can be run from any shell and directory – like any normal program on your computer. If you use pipx on your system, you can install IGA with the following command:
pipx install iga
After installation, a program named iga should end up in a location where other command-line programs are installed on your computer. Test it by running the following command in a shell:
iga --help
Alternative 2: using pip
IGA is available from the Python package repository PyPI and can be installed using pip:
python3 -m pip install iga
As an alternative to getting it from PyPI, you can install iga directly from GitHub:
python3 -m pip install git+https://github.com/caltechlibrary/iga.git
If you already installed IGA once before, and want to update to the latest version, add --upgrade to the end of either command line above.
After installation, a program named iga should end up in a location where other command-line programs are installed on your computer. Test it by running the following command in a shell:
iga --help
Alternative 3: from sources
If you prefer to install IGA directly from the source code, first obtain a copy by either downloading the source archive from the IGA releases page on GitHub, or by using git to clone the repository to a location on your computer. For example,
git clone https://github.com/caltechlibrary/iga
Next, after getting a copy of the files, run setup.py inside the code directory:
cd iga
python3 setup.py install
Once you have installed iga, the next steps are (1) get an InvenioRDM token and (2) configure iga for running locally.
IGA as a GitHub Actions workflow
A GitHub Actions workflow is an automated process that runs on GitHub's servers under control of a file in your repository. Follow these steps to create the IGA workflow file:
In the main branch of your GitHub repository, create a .github/workflows directory
In the .github/workflows directory, create a file named (e.g.) iga.yml and copy the following contents into it:
# GitHub Actions workflow for InvenioRDM GitHub Archiver version 1.3.4
# This is available as the file "sample-workflow.yml" from the open-
# source repository for IGA at https://github.com/caltechlibrary/iga/.
# ╭────────────────────────────────────────────╮
# │ Configure this section │
# ╰────────────────────────────────────────────╯
env:
# 👋🏻 Set the next variable to your InvenioRDM server address 👋🏻
INVENIO_SERVER: https://your-invenio-server.org
# Set to an InvenioRDM record ID to mark release as a new version.
parent_record: none
# The variables below are other IGA options. Please see the docs.
community: none
draft: false
all_assets: false
all_metadata: false
debug: false
# This variable is a setting for post-archiving CodeMeta file updates.
# If you don't have a CodeMeta file, you can remove the add_doi_codemeta
# and Codemeta2CFF jobs at the bottom of this file.
ref: main
# ╭────────────────────────────────────────────╮
# │ The rest of this file should be left as-is │
# ╰────────────────────────────────────────────╯
name: InvenioRDM GitHub Archiver
on:
release:
types: [published]
workflow_dispatch:
inputs:
release_tag:
description: The release tag (empty = latest)
parent_record:
description: ID of parent record (for versioning)
community:
description: Name of InvenioRDM community (if any)
draft:
description: Mark the record as a draft
type: boolean
all_assets:
description: Attach all GitHub assets
type: boolean
all_metadata:
description: Include additional GitHub metadata
type: boolean
debug:
description: Print debug info in the GitHub log
type: boolean
run-name: Archive ${{inputs.release_tag || 'latest release'}} in InvenioRDM
jobs:
run_iga:
name: Send to ${{needs.get_repository.outputs.server}}
runs-on: ubuntu-latest
needs: get_repository
outputs:
record_doi: ${{steps.iga.outputs.record_doi}}
steps:
- uses: caltechlibrary/iga@v1
id: iga
with:
INVENIO_SERVER: ${{env.INVENIO_SERVER}}
INVENIO_TOKEN: ${{secrets.INVENIO_TOKEN}}
all_assets: ${{github.event.inputs.all_assets || env.all_assets}}
all_metadata: ${{github.event.inputs.all_metadata || env.all_metadata}}
debug: ${{github.event.inputs.debug || env.debug}}
draft: ${{github.event.inputs.draft || env.draft}}
community: ${{github.event.inputs.community || env.community}}
parent_record: ${{github.event.inputs.parent_record || env.parent_record}}
release_tag: ${{github.event.inputs.release_tag || 'latest'}}
get_repository:
name: Get repository name
runs-on: ubuntu-latest
outputs:
server: ${{steps.parse.outputs.host}}
steps:
- name: Extract name from INVENIO_SERVER
id: parse
run: echo "host=$(cut -d'/' -f3 <<< ${{env.INVENIO_SERVER}} | cut -d':' -f1)" >> $GITHUB_OUTPUT
add_doi_codemeta:
name: "Add ${{needs.run_iga.outputs.record_doi}} to codemeta.json"
needs: run_iga
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.ref }}
- name: Install sde
run: pip install sde
- name: Add DOI to CodeMeta File
run: sde identifier ${{needs.run_iga.outputs.record_doi}} codemeta.json
- name: Commit CFF
uses: EndBug/add-and-commit@v9
with:
message: 'Add DOI to codemeta.json file'
add: 'codemeta.json'
CodeMeta2CFF:
runs-on: ubuntu-latest
needs: add_doi_codemeta
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ env.ref }}
- name: Convert CFF
uses: caltechlibrary/codemeta2cff@main
- name: Commit CFF
uses: EndBug/add-and-commit@v9
with:
message: 'Add updated CITATION.cff from codemeta.json file'
add: 'CITATION.cff'
Edit the value of the INVENIO_SERVER variable (line 7 above) ↑
Optionally, change the values of other options (parent_record, community, etc.)
If you have a CodeMeta file, the GitHub action workflow can automatically add the DOI after IGA has run. The "ref" value is the branch where the CodeMeta file will be updated. If you don't use a CodeMeta file, you can delete the add_doi_codemeta part of the workflow.