fmt: ran formatter and updated flake check

This commit is contained in:
2025-03-22 13:07:35 -05:00
parent 980887cfcf
commit 480312fbbd
6 changed files with 60 additions and 72 deletions

View File

@@ -2,30 +2,25 @@ name: Deploy Docker Image
on:
push:
tags:
- 'v*.*.*' # Match version tags like v1.2.3
- '*.*.*' # Match version tags like 1.2.3
- 'v*.*.*' # Match version tags like v1.2.3
- '*.*.*' # Match version tags like 1.2.3
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v31
- name: Setup Attic Cache
uses: ryanccn/attic-action@3354ae812cb672e1381be4c7914204c44db53866
with:
endpoint: ${{ secrets.ATTIC_ENDPOINT }}
cache: ${{ secrets.ATTIC_CACHE }}
token: ${{ secrets.ATTIC_TOKEN }}
- name: Build Docker image
run: |
nix build .#act-runner-image
- name: Deploy Docker image
env:
REGISTRY: ghcr.io

View File

@@ -2,6 +2,7 @@
"bumpFiles": [
{
"filename": "version.txt",
"type": "plain-text"
}
],
"sign": true,

View File

@@ -41,6 +41,10 @@
# nix fmt formatter
formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper);
checks = eachSystem (pkgs: {
formatting = treefmtEval.${pkgs.system}.config.build.check self;
});
# Docker image for Gitea Actions runner
packages = eachSystem (pkgs: {
default = self.packages.${pkgs.system}.act-runner-image;

View File

@@ -24,7 +24,7 @@ if [[ ! -f "result" ]]; then
fi
# Login to registry if credentials are provided
if [[ -n "${REGISTRY_USER}" && -n "${REGISTRY_PASSWORD}" ]]; then
if [[ -n ${REGISTRY_USER} && -n ${REGISTRY_PASSWORD} ]]; then
banner "Logging in to registry ${REGISTRY}"
echo "${REGISTRY_PASSWORD}" | skopeo login --username "${REGISTRY_USER}" --password-stdin "${REGISTRY}"
fi
@@ -34,25 +34,25 @@ banner "Inspecting Docker archive"
skopeo inspect docker-archive:result
# Determine tags based on version
if [[ -n "${TAG:-}" ]]; then
if [[ -n ${TAG:-} ]]; then
# For tagged releases, parse version numbers
VERSION="${TAG}"
if [[ "${VERSION}" =~ ^v(.+)$ ]]; then
if [[ ${VERSION} =~ ^v(.+)$ ]]; then
# Remove 'v' prefix if present
VERSION="${BASH_REMATCH[1]}"
fi
# Split version into components
IFS='.' read -r MAJOR MINOR PATCH <<< "${VERSION}"
IFS='.' read -r MAJOR MINOR _PATCH <<<"${VERSION}"
TAGS=("${VERSION}")
if [[ -n "${MAJOR}" && -n "${MINOR}" ]]; then
if [[ -n ${MAJOR} && -n ${MINOR} ]]; then
TAGS+=("${MAJOR}.${MINOR}")
fi
if [[ -n "${MAJOR}" ]]; then
if [[ -n ${MAJOR} ]]; then
TAGS+=("${MAJOR}")
fi
banner "Deploying version: ${VERSION} (tags: ${TAGS[*]})"
else
# For non-tag builds (master), just use latest

View File

@@ -2,51 +2,50 @@
set -Eeuo pipefail
if [ -z "$(git status --porcelain)" ]; then
branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}
branch_name=${branch_name:-HEAD}
if [ $branch_name != "master" ]; then
echo "The current branch is not master!"
echo "I'd feel uncomfortable releasing from here..."
exit 3
fi
branch_name=$(git symbolic-ref -q HEAD)
branch_name=${branch_name##refs/heads/}
branch_name=${branch_name:-HEAD}
if [ "$branch_name" != "master" ]; then
echo "The current branch is not master!"
echo "I'd feel uncomfortable releasing from here..."
exit 3
fi
release_needed=false
if \
{ git log "$( git describe --tags --abbrev=0 )..HEAD" --format='%s' | cut -d: -f1 | sort -u | sed -e 's/([^)]*)//' | grep -q -i -E '^feat|fix|perf|refactor|revert$' ; } || \
{ git log "$( git describe --tags --abbrev=0 )..HEAD" --format='%s' | cut -d: -f1 | sort -u | sed -e 's/([^)]*)//' | grep -q -E '\!$' ; } || \
{ git log "$( git describe --tags --abbrev=0 )..HEAD" --format='%b' | grep -q -E '^BREAKING CHANGE:' ; }
then
release_needed=true
fi
if ! [ "$release_needed" = true ]; then
echo "No release needed..."
exit 0
fi
release_needed=false
if
{ git log "$(git describe --tags --abbrev=0)..HEAD" --format='%s' | cut -d: -f1 | sort -u | sed -e 's/([^)]*)//' | grep -q -i -E '^feat|fix|perf|refactor|revert$'; } ||
{ git log "$(git describe --tags --abbrev=0)..HEAD" --format='%s' | cut -d: -f1 | sort -u | sed -e 's/([^)]*)//' | grep -q -E '\!$'; } ||
{ git log "$(git describe --tags --abbrev=0)..HEAD" --format='%b' | grep -q -E '^BREAKING CHANGE:'; }
then
release_needed=true
fi
std_version_args=()
if [[ -n "${1:-}" ]]; then
std_version_args+=( "--release-as" "$1" )
echo "Parameter $1 was supplied, so we should use release-as"
else
echo "No release-as parameter specifed."
fi
# Working directory clean
echo "Doing a dry run..."
npx commit-and-tag-version --dry-run "${std_version_args[@]}"
read -p "Does that look good? [y/N] " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# do dangerous stuff
npx commit-and-tag-version "${std_version_args[@]}"
git push --follow-tags origin master
else
echo "okay, never mind then..."
exit 2
fi
else
echo "Can't create release, working tree unclean..."
exit 1
if ! [ "$release_needed" = true ]; then
echo "No release needed..."
exit 0
fi
std_version_args=()
if [[ -n ${1:-} ]]; then
std_version_args+=("--release-as" "$1")
echo "Parameter $1 was supplied, so we should use release-as"
else
echo "No release-as parameter specifed."
fi
# Working directory clean
echo "Doing a dry run..."
npx commit-and-tag-version --dry-run "${std_version_args[@]}"
read -p "Does that look good? [y/N] " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
# do dangerous stuff
npx commit-and-tag-version "${std_version_args[@]}"
git push --follow-tags origin master
else
echo "okay, never mind then..."
exit 2
fi
else
echo "Can't create release, working tree unclean..."
exit 1
fi

View File

@@ -1,11 +0,0 @@
const pattern = /(\[tool\.poetry\]\nname = "kalpaa"\nversion = ")(?<vers>\d+\.\d+\.\d+)(")/mg;
module.exports.readVersion = function (contents) {
const result = pattern.exec(contents);
return result.groups.vers;
}
module.exports.writeVersion = function (contents, version) {
const newContents = contents.replace(pattern, `$1${version}$3`);
return newContents;
}