aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Mark <[email protected]>2022-06-01 12:28:26 -0700
committerGravatar GitHub <[email protected]>2022-06-01 12:28:26 -0700
commit8ca7da31124a95b3f323fe285904b4f6e4be8e56 (patch)
treebaa0cf569ce91124dc1a94ee9755d79b5e86315b
parentMerge #140 - add pyproject.toml and versioning (diff)
parentCI: print the version to help with debugging (diff)
Merge #141 - fix version commit count
-rw-r--r--.github/workflows/build.yaml4
-rw-r--r--.github/workflows/deploy.yaml4
-rw-r--r--README.md1
-rw-r--r--scripts/version.py3
4 files changed, 9 insertions, 3 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index e5791c9..c8d7a68 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
@@ -28,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
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'.
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.
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__":