From 1a443375e0fda4d9fa046ff9b22f7dbcb88d2691 Mon Sep 17 00:00:00 2001 From: MarkKoz <1515135+MarkKoz@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:09:36 -0700 Subject: Fix commit count part of version being off by 1 --- scripts/version.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/version.py b/scripts/version.py index bf8d509..62ff07e 100644 --- a/scripts/version.py +++ b/scripts/version.py @@ -31,7 +31,8 @@ def count_commits_on_date(dt: datetime.datetime) -> int: args = ["git", "log", "--oneline", "--after", str(dt.timestamp())] stdout = subprocess.check_output(args, text=True) - return stdout.strip().count("\n") + # The last newline is stripped, so it has to be manually counted with + 1. + return stdout.strip().count("\n") + 1 if __name__ == "__main__": -- cgit v1.2.3 From 7ac15ad4654e94aaf28b33846b7437c748a84fe3 Mon Sep 17 00:00:00 2001 From: MarkKoz <1515135+MarkKoz@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:11:51 -0700 Subject: CI: fetch git history to fix version script The last part of the version is the commit count, which relies on the repo's commit history. --- .github/workflows/build.yaml | 3 +++ .github/workflows/deploy.yaml | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e5791c9..b878113 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,6 +21,9 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + with: + # The version script relies on history. Fetch 100 commits to be safe. + fetch-depth: 100 - name: Get version id: version diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 9113188..82903f8 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -36,9 +36,11 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - # The Dockerfile will be needed. - name: Checkout code uses: actions/checkout@v2 + with: + # The version script relies on history. Fetch 100 commits to be safe. + fetch-depth: 100 # Build the final production image and push it to GHCR. # Tag it with both the short commit SHA and 'latest'. -- cgit v1.2.3 From 10caf4b3e6aded35435f917c4546e679753c7dfd Mon Sep 17 00:00:00 2001 From: MarkKoz <1515135+MarkKoz@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:12:18 -0700 Subject: Remove GIT_SHA from README.md The env var is no longer used anywhere. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b18aef8..2e2ee9c 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,6 @@ All environment variables have defaults and are therefore not required to be set Name | Description ---- | ----------- `DEBUG` | Enable debug logging if set to a non-empty value. -`GIT_SHA` | [Sentry release] identifier. Set in CI. `NSJAIL_CFG` | Path to the NsJail configuration file. `NSJAIL_PATH` | Path to the NsJail binary. `SNEKBOX_SENTRY_DSN` | [Data Source Name] for Sentry. Sentry is disabled if left unset. -- cgit v1.2.3 From 433a30a20a4f54bb19259377f0d0995a65d66c04 Mon Sep 17 00:00:00 2001 From: MarkKoz <1515135+MarkKoz@users.noreply.github.com> Date: Wed, 1 Jun 2022 12:15:08 -0700 Subject: CI: print the version to help with debugging --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b878113..c8d7a68 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -31,6 +31,7 @@ jobs: set -eu version=$(python scripts/version.py) echo "::set-output name=version::version" + printf "%s\n" "${version}" # The current version (v2) of Docker's build-push action uses buildx, # which comes with BuildKit. It has cache features which can speed up -- cgit v1.2.3