Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display version on deployed github page #7

Open
s-l-teichmann opened this issue Aug 2, 2023 · 11 comments
Open

Display version on deployed github page #7

s-l-teichmann opened this issue Aug 2, 2023 · 11 comments
Assignees

Comments

@s-l-teichmann
Copy link
Contributor

Currently there is no user accessible way to tell which version is served as a Github page.
That should be possible.

@tschmidtb51
Copy link

The version string can be extracted during the build of the GH-pages. We do something similar for Secvisogram - but maybe an easier method can be found (e.g. executing git describe during the build process).

@ThomasJunk
Copy link
Contributor

I tried to implement an easy solution with

Leveraging git describe to retrieve info and redirect it to a VERSION file.
On starting/building I include this information into the runtime context of the app.

This should do the trick (for now).

@ThomasJunk
Copy link
Contributor

ThomasJunk commented Aug 23, 2023

TIL: git describe behaves tricky in the context of GithubActions and in consequence broke integration testing even before starting to test.

In e53a94b I switched to the even simpler concept of using the version info of package.json.

@ThomasJunk
Copy link
Contributor

version
So it looks like this (for now). I think we can discuss general layout later.

@tschmidtb51
Copy link

TIL: git describe behaves tricky in the context of GithubActions and in consequence broke integration testing even before starting to test.

@ThomasJunk: Actually, the checkout/action does only do a shallow checkout by default (which does not capture the tags). In order to do that, you have to run git fetch --depth=1 origin +refs/tags/*:refs/tags/* after the checkout (see https://github.com/secvisogram/secvisogram/blob/main/.github/workflows/github-pages.yml as example). Note: tags need to be annotated - otherwise this will fail.

The nice thing about this approach is, that it already works in development (with each commit) without having to update the version in the package.json ;-)

@bernhardreiter
Copy link
Contributor

@ThomasJunk see https://github.com/csaf-poc/csaf_distribution/blob/7d3c3a68df05e48640e8e2eaec53ee23bb370285/Makefile#L40-L58 for an example that results into a semver compatible version after using git describe in different situations within Github Actions. If fitting, please use that method.

@ThomasJunk
Copy link
Contributor

ThomasJunk commented Oct 25, 2023

Is it necessary / meaningful to do this as a github action?
ATM we read from the package.json. So it might be a better idea to do this via commit hooks and commit the changed package.json (with the updated version number) along with the other files of the commit? So we always have an up to date version in package.json.

As a hint: https://stackoverflow.com/a/55427831/411645 shows a "recipe" for such a hook. Instead of using bump.js we could do our git describe-logic within that script.

Or use npm version to accomplish our task.

@tschmidtb51
Copy link

In general, I'm not a big fan of the package.json solution as it requires somebody to update the package.json. At the end, the solution needs to work - independent which way the user took:

  1. create a release via Github
  2. local tags of a version that then gets pushed
  3. ...

Therefore, I would like to rely on Git tags instead.

Nevertheless, if there is a way to keep tags and the version the package.json and the package-lock.json consistent in each of these cases - please let me know.

BTW: GithubActions use a shallow checkout - that's why I linked to our solution for Secvisogram.

@ThomasJunk
Copy link
Contributor

As far as my understanding goes npm version should do the thing requested:

Run this in a package directory to bump the version and write the new data back to package.json, package-lock.json, and, if present, npm-shrinkwrap.json.

If run in a git repo, it will also create a version commit and tag.

There is even a possibility to use the latest git-tag as a source

from-git will try to read the latest git tag, and use that as the new npm version.

which meets the requirement of

Therefore, I would like to rely on Git tags instead.

The package.json then is only the destination where a current version is written to and the source for the application where it is read from.

And this should run too in the context of a github action.

@bernhardreiter
Copy link
Contributor

Just to remind: Using the latest git tag is not enough for development versions as it would display the wrong version.

@JanHoefelmeyer
Copy link
Contributor

Not yet automated via github actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants