An example GitHub repository and GitHub workflow that could be used to self-host an internal (private) SysML v2 Project Index for use with Sysand.
This example is not intended to be the one and only approach for self-hosting a project index, but rather a way to quickly spin up an initial index. The included GitHub workflow is also very minimal and the end-users should customise it for their needs (e.g. adding quality gates).
Note
Since GitHub Pages do not allow authorization using Personal Access
Tokens, this example is a workaround that uses
raw.githubusercontent.com to expose the files to Sysand CLI.
Sensmetry cannot guarantee that accessing files through
raw.githubusercontent.com will not be rate-limited by GitHub, thus if you
expect a large volume of requests going to this index, this solution might
not be ideal.
The URL of the index will look something like this:
https://raw.githubusercontent.com/OWNER/REPO/refs/heads/index/
- Commit to
mainwith.kparfile added to thepackages/<project>/folder.- The internal package registry uses the
urn:kpar:+ thenamefield from.project.jsonfor the IRI. - Thus, to make referencing the package easier, the
nameshall be ASCII-only, with no spaces (-strongly encouraged to be used in place of the space), lowercase-only, and no longer than 32 characters. Other rules can be set up internally, but then the CI workflow needs to be adjusted to account for that (e.g. if allowing spaces in the name). - The
<project>folder should be called the same as thenamefor easier file discovery in the repo itself, but otherwise there is no strict rule. - The name of the
.kparfile does not matter, but it is strongly suggested for it to have a version number inside it, so that if there are multiple versions of the same project, the.kpars do not overwrite each other accidentally.
- The internal package registry uses the
- When commit lands on
main, a new workflow starts that:- Uses Sysand to create an environment (
sysand env) - Uses Sysand to install all
.kpars frompackages/**folder (sysand env install --path /path/to/kpar --no-deps --allow-multiple <IRI as described in step 1.>) - Copies all contents of
sysand_envfolder toindexfolder and saves the index folder as an artifact - Checks out the
indexbranch,git reset --hards to a commit that made theindexbranch have no files. - Extracts the
indexcontents from the build artifact. git adds all the contents, commits the changes withPublish Indexcommit, and force pushes * toindexbranch.
- Uses Sysand to create an environment (
* NOTE: Force pushing is used to avoid making the git repo size from
exploding with each commit. Additionally, the index branch should not be used
by humans, and it only contains the automatically generated artifacts. Ideally,
the branch should be protected and only the bot account should be able to push
to it.
- Create a GitHub Personal Access
Token (we recommend
using fine-grained tokens) scoped to the index repository and the
Contentsread-only permissions. - Create a
.envfile or use other means to set the following environment variables. For<X>you can use whatever you want.SYSAND_CRED_<X>with the valuehttps://raw.githubusercontent.com/OWNER/REPO/refs/heads/index/**(therefs/heads/index/**part is important!)SYSAND_CRED_<X>_BEARER_TOKENwith the value set to the Personal Access Token generated in step 1.- For more information about how Sysand deals with Authentication, refer to Sysand documentation.
- An example
.env.examplefile is provided in this repo.
- Use the
--indexSysand CLI argument with the value ofhttps://raw.githubusercontent.com/OWNER/REPO/refs/heads/index/when installing the packages from this index OR usesysand.tomlconfig file with the index set there.- For more information about how to set up Sysand to use custom indices, refer to Sysand documentation.
- An example
sysand.tomlconfig file is provided in this repo.
You need to set up a GitHub repo as follows:
- Commit anything to the
mainbranch. - Push the
mainbranch to GitHub. - Create an
indexbranch from the initial commit. - Delete all files from the repo, and commit the deletion to the
indexbranch (blue circle in the above diagram). - Note down the SHA of the deletion commit.
- Push the
indexbranch to GitHub. - Check out
mainbranch again. - Enter that SHA into the
.github/workflows/ci.ymlfile, line 54 (the one withgit reset --hard). - Commit and push the SHA change.
- You should be good to go! Whenever you add a
.kparfile to thepackagesfolder, the CI should trigger and the package should become available throughsysand addorsysand clone.
Don't forget to update the OWNER/REPO parts of the raw.githubusercontent.com
URLs in this README.md, .env.example, and
sysand.toml files, to make it easier for your colleagues to
access the index URL.
