Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,10 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build.bash -p

- uses: actions/upload-artifact@v4
with:
name: Buildscript
path: package/buildscript-*.zip
if-no-files-found: ignore

12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.3] - 2025-10-09

- Revert broken build changes
- Improve release-prep.bash and release-publish.bash scripts
- Change to manual deployment method
- Revise and streamline Dockerfile
- Add copy of release-publish script to Dockerfile

## [1.3.2] - 2025-09-17

Expand DownExpand Up@@ -49,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GitHub workflow `build.yml` to show how to call the script as a GitHub Action

[unreleased]: https://github.com/mcld/buildscript/compare/v1.3.0...HEAD
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.3.3]: https://github.com/mcld/buildscript/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/mcld/buildscript/compare/v1.3.0...v1.3.2
[1.3.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mcld/buildscript/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/mcld/buildscript/compare/v1.0.0...v1.0.1
Expand Down
73 changes: 41 additions & 32 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,60 @@
# prepare base image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

# get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy source
COPY . ./

# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown

# run dotnet restore
COPY ["buildscript/buildscript.csproj", "buildscript/"]
RUN dotnet restore "buildscript/buildscript.csproj"
# Restore packages
RUN dotnet restore

# copy source and build
COPY . .
WORKDIR "/src/buildscript"
RUN dotnet build "buildscript.csproj" -c Release -o /app/build
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0

# create publish image
FROM build AS publish
RUN dotnet publish "buildscript.csproj" -c Release -o /app/publish
# Publish release project
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/

# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"

# Copy actual build script
RUN cp /app/build.bash "/app/publish/"

# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish

# copy published app to final
FROM base AS final
WORKDIR /app

# Bring in metadata via --build-arg
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown

# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build script test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
LABEL branch=$BRANCH \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build scrip test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION

# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION

# Copy source
COPY --from=build "/app/publish/" .

COPY --from=publish /app/publish .
# Set entrypoint
ENTRYPOINT ["dotnet", "buildscript.dll"]
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ Options (all are optional):
- `-h, --help` - Print this help and exit
- `-v, --verbose` - Print script debug info
- `-df, --dockerfile` - Use the specified Dockerfile
- `-p, --publish` - Run the release-publish.bash script in the container(if it's present)
- `-p, --publish` - Run the release-prep and (in container) release-publish scripts (if present)
- `Docker tag` - Override the guessed Docker tag (the current directory) with this value if present

Environment variables (all are optional):
Expand Down
15 changes: 7 additions & 8 deletions build.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,8 @@ Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-df, --dockerfile Use the specified Dockerfile
-p, --publish Run the release-publish.bash script in the container (if it's present)
--no-color Do not use color codes in script output
-p, --publish Run release-prep.bash and (in container) release-publish.bash (if present)

Environment variables:

Expand All@@ -38,7 +39,7 @@ Environment variables:
- GHCR_PAT - optional - GitHub Container Registry Personal Access Token
- GHCR_USER - optional - username to log in to the GitHub Container Registry

Version 1.3.2 released 2025-09-17
Version 1.3.3 released 2025-10-09
EOF
exit
}
Expand DownExpand Up@@ -116,7 +117,7 @@ readonly SYSARCH

if [[ ${SYSARCH} = "i386" ]]; then
readonly ARCH="x86_32"
elif [[ ${SYSARCH} = "aarch64" ]]; then
elif [[ ${SYSARCH} = "aarch64" ]]; then
readonly ARCH="armv7"
else
readonly ARCH=${SYSARCH}
Expand DownExpand Up@@ -162,11 +163,11 @@ fi
if [[ $BLD_BRANCH = "develop"
|| $BLD_BRANCH = "main"
|| $BLD_BRANCH = "master"
|| $BLD_BRANCH = "test" ]]; then
|| $BLD_BRANCH = "test" ]]; then
BLD_DOCKER_TAG=$BLD_BRANCH
BLD_VERSION=${BLD_BRANCH}-${BLD_VERSION_DATE}
BLD_PUSH=true
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
BLD_RELEASE_VERSION=${BASH_REMATCH[1]}
BLD_DOCKER_TAG=v${BLD_RELEASE_VERSION}
BLD_VERSION=v${BLD_RELEASE_VERSION}
Expand DownExpand Up@@ -202,7 +203,7 @@ fi
if [[ $BLD_RELEASE = "true" && -x "release-prep.bash" ]]; then
msg "${BLUE}===${NOFORMAT} Running release preparation for version $BLD_RELEASE_VERSION"
#shellcheck disable=SC1091
./release-prep.bash
source release-prep.bash
msg "${GREEN}===${NOFORMAT} Release preparation script complete"
fi

Expand DownExpand Up@@ -311,15 +312,13 @@ if [[ $BLD_PUSH = true ]]; then
--entrypoint "/app/release-publish.bash" \
--env-file release.env \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
else
docker run -i \
--rm \
--entrypoint "/app/release-publish.bash" \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
fi
Expand Down
2 changes: 2 additions & 0 deletions buildscript.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.bash = build.bash
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
Dockerfile = Dockerfile
LICENSE.md = LICENSE.md
README.md = README.md
release-prep.bash = release-prep.bash
release-publish.bash = release-publish.bash
Expand Down
79 changes: 43 additions & 36 deletions release-prep.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,68 +7,75 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v]

Fake release prep script.
Pre-build release preparation script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-p Perform publish steps
-v, --verbose Print script debug info
EOF
exit
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
param=''

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
# default values of variables set from params
publish=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-p | --publish) publish=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

return 0
}

parse_params "$@"
setup_colors

# script logic here

msg "... release-prep.bash is preparing for release"
sleep 2
msg "... release-prep.bash has prepared for release."
readonly PUB_STARTAT=$SECONDS

if [[ publish -eq 1 ]]; then
msg "${BLUE}===${NOFORMAT} Performing publish release prep"
sleep 2
msg "${PURPLE}===${NOFORMAT} Release prep successful in $((SECONDS - PUB_STARTAT)) seconds."
else
msg "${RED}===${NOFORMAT} Missing -p flag, not running release prep"
fi

37 changes: 12 additions & 25 deletions release-publish.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Script description here.
Post-build release processing script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-v, --verbose Print script debug info
EOF
exit
Expand DownExpand Up@@ -63,34 +64,20 @@ parse_params() {
parse_params "$@"
setup_colors

readonly BLD_PUBLISH_DIRECTORY=buildscript-${BLD_RELEASE_VERSION-}
#script logic here

msg "=== Installing necessary packages"
apt update && apt install build-essential zip -y
readonly PUB_STARTAT=$SECONDS

cd /
msg "${BLUE}===${NOFORMAT} Installing zip package"

msg "=== Making directory ${BLD_PUBLISH_DIRECTORY-}"
mkdir -p "${BLD_PUBLISH_DIRECTORY-}"
apt-get update && apt-get install zip -y

msg "=== Copying files into ${BLD_PUBLISH_DIRECTORY-}"
cp -a app/* "${BLD_PUBLISH_DIRECTORY-}"
msg "${BLUE}===${NOFORMAT} Publishing to buildscript-${BLD_RELEASE_VERSION}.zip"

msg "=== Compressing files"
zip -q -r9 "buildscript-${BLD_RELEASE_VERSION-}.zip" "${BLD_PUBLISH_DIRECTORY-}"/
mkdir -p "/package" && \
cd /app && \
zip -q -r9 "/package/buildscript-${BLD_RELEASE_VERSION}.zip" "build.bash" && \
du -sh "/package/buildscript-${BLD_RELEASE_VERSION}.zip"

du -sch "${BLD_PUBLISH_DIRECTORY-}"/ "buildscript-${BLD_RELEASE_VERSION-}.zip"
msg "${PURPLE}===${NOFORMAT} Publish script complete in $((SECONDS - PUB_STARTAT)) seconds."

if [[ -n "${BLD_RELEASE_TOKEN-}" ]]; then
curl -L -O https://github.com/tfausak/github-release/releases/latest/download/github-release-linux.gz
gunzip github-release-linux.gz && chmod 700 github-release-linux && \
./github-release-linux upload \
--token "${BLD_RELEASE_TOKEN-}" \
--owner "${BLD_RELEASE_OWNER-}" \
--repo "${BLD_RELEASE_REPO-}" \
--tag "v${BLD_RELEASE_VERSION-}" \
--file "buildscript-${BLD_RELEASE_VERSION-}.zip" \
--name "buildscript-${BLD_RELEASE_VERSION-}.zip"
else
echo "=== No BLD_RELEASE_TOKEN configured, not pushing release artifacts to GitHub Releases"
fi
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,10 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build.bash -p

- uses: actions/upload-artifact@v4
with:
name: Buildscript
path: package/buildscript-*.zip
if-no-files-found: ignore

12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.3] - 2025-10-09

- Revert broken build changes
- Improve release-prep.bash and release-publish.bash scripts
- Change to manual deployment method
- Revise and streamline Dockerfile
- Add copy of release-publish script to Dockerfile

## [1.3.2] - 2025-09-17

Expand DownExpand Up@@ -49,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GitHub workflow `build.yml` to show how to call the script as a GitHub Action

[unreleased]: https://github.com/mcld/buildscript/compare/v1.3.0...HEAD
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.3.3]: https://github.com/mcld/buildscript/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/mcld/buildscript/compare/v1.3.0...v1.3.2
[1.3.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mcld/buildscript/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/mcld/buildscript/compare/v1.0.0...v1.0.1
Expand Down
73 changes: 41 additions & 32 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,60 @@
# prepare base image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

# get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy source
COPY . ./

# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown

# run dotnet restore
COPY ["buildscript/buildscript.csproj", "buildscript/"]
RUN dotnet restore "buildscript/buildscript.csproj"
# Restore packages
RUN dotnet restore

# copy source and build
COPY . .
WORKDIR "/src/buildscript"
RUN dotnet build "buildscript.csproj" -c Release -o /app/build
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0

# create publish image
FROM build AS publish
RUN dotnet publish "buildscript.csproj" -c Release -o /app/publish
# Publish release project
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/

# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"

# Copy actual build script
RUN cp /app/build.bash "/app/publish/"

# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish

# copy published app to final
FROM base AS final
WORKDIR /app

# Bring in metadata via --build-arg
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown

# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build script test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
LABEL branch=$BRANCH \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build scrip test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION

# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION

# Copy source
COPY --from=build "/app/publish/" .

COPY --from=publish /app/publish .
# Set entrypoint
ENTRYPOINT ["dotnet", "buildscript.dll"]
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ Options (all are optional):
- `-h, --help` - Print this help and exit
- `-v, --verbose` - Print script debug info
- `-df, --dockerfile` - Use the specified Dockerfile
- `-p, --publish` - Run the release-publish.bash script in the container(if it's present)
- `-p, --publish` - Run the release-prep and (in container) release-publish scripts (if present)
- `Docker tag` - Override the guessed Docker tag (the current directory) with this value if present

Environment variables (all are optional):
Expand Down
15 changes: 7 additions & 8 deletions build.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,8 @@ Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-df, --dockerfile Use the specified Dockerfile
-p, --publish Run the release-publish.bash script in the container (if it's present)
--no-color Do not use color codes in script output
-p, --publish Run release-prep.bash and (in container) release-publish.bash (if present)

Environment variables:

Expand All@@ -38,7 +39,7 @@ Environment variables:
- GHCR_PAT - optional - GitHub Container Registry Personal Access Token
- GHCR_USER - optional - username to log in to the GitHub Container Registry

Version 1.3.2 released 2025-09-17
Version 1.3.3 released 2025-10-09
EOF
exit
}
Expand DownExpand Up@@ -116,7 +117,7 @@ readonly SYSARCH

if [[ ${SYSARCH} = "i386" ]]; then
readonly ARCH="x86_32"
elif [[ ${SYSARCH} = "aarch64" ]]; then
elif [[ ${SYSARCH} = "aarch64" ]]; then
readonly ARCH="armv7"
else
readonly ARCH=${SYSARCH}
Expand DownExpand Up@@ -162,11 +163,11 @@ fi
if [[ $BLD_BRANCH = "develop"
|| $BLD_BRANCH = "main"
|| $BLD_BRANCH = "master"
|| $BLD_BRANCH = "test" ]]; then
|| $BLD_BRANCH = "test" ]]; then
BLD_DOCKER_TAG=$BLD_BRANCH
BLD_VERSION=${BLD_BRANCH}-${BLD_VERSION_DATE}
BLD_PUSH=true
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
BLD_RELEASE_VERSION=${BASH_REMATCH[1]}
BLD_DOCKER_TAG=v${BLD_RELEASE_VERSION}
BLD_VERSION=v${BLD_RELEASE_VERSION}
Expand DownExpand Up@@ -202,7 +203,7 @@ fi
if [[ $BLD_RELEASE = "true" && -x "release-prep.bash" ]]; then
msg "${BLUE}===${NOFORMAT} Running release preparation for version $BLD_RELEASE_VERSION"
#shellcheck disable=SC1091
./release-prep.bash
source release-prep.bash
msg "${GREEN}===${NOFORMAT} Release preparation script complete"
fi

Expand DownExpand Up@@ -311,15 +312,13 @@ if [[ $BLD_PUSH = true ]]; then
--entrypoint "/app/release-publish.bash" \
--env-file release.env \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
else
docker run -i \
--rm \
--entrypoint "/app/release-publish.bash" \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
fi
Expand Down
2 changes: 2 additions & 0 deletions buildscript.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.bash = build.bash
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
Dockerfile = Dockerfile
LICENSE.md = LICENSE.md
README.md = README.md
release-prep.bash = release-prep.bash
release-publish.bash = release-publish.bash
Expand Down
79 changes: 43 additions & 36 deletions release-prep.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,68 +7,75 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v]

Fake release prep script.
Pre-build release preparation script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-p Perform publish steps
-v, --verbose Print script debug info
EOF
exit
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
param=''

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
# default values of variables set from params
publish=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-p | --publish) publish=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

return 0
}

parse_params "$@"
setup_colors

# script logic here

msg "... release-prep.bash is preparing for release"
sleep 2
msg "... release-prep.bash has prepared for release."
readonly PUB_STARTAT=$SECONDS

if [[ publish -eq 1 ]]; then
msg "${BLUE}===${NOFORMAT} Performing publish release prep"
sleep 2
msg "${PURPLE}===${NOFORMAT} Release prep successful in $((SECONDS - PUB_STARTAT)) seconds."
else
msg "${RED}===${NOFORMAT} Missing -p flag, not running release prep"
fi

37 changes: 12 additions & 25 deletions release-publish.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Script description here.
Post-build release processing script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-v, --verbose Print script debug info
EOF
exit
Expand DownExpand Up@@ -63,34 +64,20 @@ parse_params() {
parse_params "$@"
setup_colors

readonly BLD_PUBLISH_DIRECTORY=buildscript-${BLD_RELEASE_VERSION-}
#script logic here

msg "=== Installing necessary packages"
apt update && apt install build-essential zip -y
readonly PUB_STARTAT=$SECONDS

cd /
msg "${BLUE}===${NOFORMAT} Installing zip package"

msg "=== Making directory ${BLD_PUBLISH_DIRECTORY-}"
mkdir -p "${BLD_PUBLISH_DIRECTORY-}"
apt-get update && apt-get install zip -y

msg "=== Copying files into ${BLD_PUBLISH_DIRECTORY-}"
cp -a app/* "${BLD_PUBLISH_DIRECTORY-}"
msg "${BLUE}===${NOFORMAT} Publishing to buildscript-${BLD_RELEASE_VERSION}.zip"

msg "=== Compressing files"
zip -q -r9 "buildscript-${BLD_RELEASE_VERSION-}.zip" "${BLD_PUBLISH_DIRECTORY-}"/
mkdir -p "/package" && \
cd /app && \
zip -q -r9 "/package/buildscript-${BLD_RELEASE_VERSION}.zip" "build.bash" && \
du -sh "/package/buildscript-${BLD_RELEASE_VERSION}.zip"

du -sch "${BLD_PUBLISH_DIRECTORY-}"/ "buildscript-${BLD_RELEASE_VERSION-}.zip"
msg "${PURPLE}===${NOFORMAT} Publish script complete in $((SECONDS - PUB_STARTAT)) seconds."

if [[ -n "${BLD_RELEASE_TOKEN-}" ]]; then
curl -L -O https://github.com/tfausak/github-release/releases/latest/download/github-release-linux.gz
gunzip github-release-linux.gz && chmod 700 github-release-linux && \
./github-release-linux upload \
--token "${BLD_RELEASE_TOKEN-}" \
--owner "${BLD_RELEASE_OWNER-}" \
--repo "${BLD_RELEASE_REPO-}" \
--tag "v${BLD_RELEASE_VERSION-}" \
--file "buildscript-${BLD_RELEASE_VERSION-}.zip" \
--name "buildscript-${BLD_RELEASE_VERSION-}.zip"
else
echo "=== No BLD_RELEASE_TOKEN configured, not pushing release artifacts to GitHub Releases"
fi
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,10 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build.bash -p

- uses: actions/upload-artifact@v4
with:
name: Buildscript
path: package/buildscript-*.zip
if-no-files-found: ignore

12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.3] - 2025-10-09

- Revert broken build changes
- Improve release-prep.bash and release-publish.bash scripts
- Change to manual deployment method
- Revise and streamline Dockerfile
- Add copy of release-publish script to Dockerfile

## [1.3.2] - 2025-09-17

Expand DownExpand Up@@ -49,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GitHub workflow `build.yml` to show how to call the script as a GitHub Action

[unreleased]: https://github.com/mcld/buildscript/compare/v1.3.0...HEAD
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.3.3]: https://github.com/mcld/buildscript/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/mcld/buildscript/compare/v1.3.0...v1.3.2
[1.3.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mcld/buildscript/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/mcld/buildscript/compare/v1.0.0...v1.0.1
Expand Down
73 changes: 41 additions & 32 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,60 @@
# prepare base image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

# get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy source
COPY . ./

# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown

# run dotnet restore
COPY ["buildscript/buildscript.csproj", "buildscript/"]
RUN dotnet restore "buildscript/buildscript.csproj"
# Restore packages
RUN dotnet restore

# copy source and build
COPY . .
WORKDIR "/src/buildscript"
RUN dotnet build "buildscript.csproj" -c Release -o /app/build
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0

# create publish image
FROM build AS publish
RUN dotnet publish "buildscript.csproj" -c Release -o /app/publish
# Publish release project
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/

# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"

# Copy actual build script
RUN cp /app/build.bash "/app/publish/"

# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish

# copy published app to final
FROM base AS final
WORKDIR /app

# Bring in metadata via --build-arg
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown

# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build script test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
LABEL branch=$BRANCH \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build scrip test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION

# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION

# Copy source
COPY --from=build "/app/publish/" .

COPY --from=publish /app/publish .
# Set entrypoint
ENTRYPOINT ["dotnet", "buildscript.dll"]
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ Options (all are optional):
- `-h, --help` - Print this help and exit
- `-v, --verbose` - Print script debug info
- `-df, --dockerfile` - Use the specified Dockerfile
- `-p, --publish` - Run the release-publish.bash script in the container(if it's present)
- `-p, --publish` - Run the release-prep and (in container) release-publish scripts (if present)
- `Docker tag` - Override the guessed Docker tag (the current directory) with this value if present

Environment variables (all are optional):
Expand Down
15 changes: 7 additions & 8 deletions build.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,8 @@ Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-df, --dockerfile Use the specified Dockerfile
-p, --publish Run the release-publish.bash script in the container (if it's present)
--no-color Do not use color codes in script output
-p, --publish Run release-prep.bash and (in container) release-publish.bash (if present)

Environment variables:

Expand All@@ -38,7 +39,7 @@ Environment variables:
- GHCR_PAT - optional - GitHub Container Registry Personal Access Token
- GHCR_USER - optional - username to log in to the GitHub Container Registry

Version 1.3.2 released 2025-09-17
Version 1.3.3 released 2025-10-09
EOF
exit
}
Expand DownExpand Up@@ -116,7 +117,7 @@ readonly SYSARCH

if [[ ${SYSARCH} = "i386" ]]; then
readonly ARCH="x86_32"
elif [[ ${SYSARCH} = "aarch64" ]]; then
elif [[ ${SYSARCH} = "aarch64" ]]; then
readonly ARCH="armv7"
else
readonly ARCH=${SYSARCH}
Expand DownExpand Up@@ -162,11 +163,11 @@ fi
if [[ $BLD_BRANCH = "develop"
|| $BLD_BRANCH = "main"
|| $BLD_BRANCH = "master"
|| $BLD_BRANCH = "test" ]]; then
|| $BLD_BRANCH = "test" ]]; then
BLD_DOCKER_TAG=$BLD_BRANCH
BLD_VERSION=${BLD_BRANCH}-${BLD_VERSION_DATE}
BLD_PUSH=true
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
BLD_RELEASE_VERSION=${BASH_REMATCH[1]}
BLD_DOCKER_TAG=v${BLD_RELEASE_VERSION}
BLD_VERSION=v${BLD_RELEASE_VERSION}
Expand DownExpand Up@@ -202,7 +203,7 @@ fi
if [[ $BLD_RELEASE = "true" && -x "release-prep.bash" ]]; then
msg "${BLUE}===${NOFORMAT} Running release preparation for version $BLD_RELEASE_VERSION"
#shellcheck disable=SC1091
./release-prep.bash
source release-prep.bash
msg "${GREEN}===${NOFORMAT} Release preparation script complete"
fi

Expand DownExpand Up@@ -311,15 +312,13 @@ if [[ $BLD_PUSH = true ]]; then
--entrypoint "/app/release-publish.bash" \
--env-file release.env \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
else
docker run -i \
--rm \
--entrypoint "/app/release-publish.bash" \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
fi
Expand Down
2 changes: 2 additions & 0 deletions buildscript.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.bash = build.bash
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
Dockerfile = Dockerfile
LICENSE.md = LICENSE.md
README.md = README.md
release-prep.bash = release-prep.bash
release-publish.bash = release-publish.bash
Expand Down
79 changes: 43 additions & 36 deletions release-prep.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,68 +7,75 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v]

Fake release prep script.
Pre-build release preparation script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-p Perform publish steps
-v, --verbose Print script debug info
EOF
exit
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
param=''

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
# default values of variables set from params
publish=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-p | --publish) publish=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

return 0
}

parse_params "$@"
setup_colors

# script logic here

msg "... release-prep.bash is preparing for release"
sleep 2
msg "... release-prep.bash has prepared for release."
readonly PUB_STARTAT=$SECONDS

if [[ publish -eq 1 ]]; then
msg "${BLUE}===${NOFORMAT} Performing publish release prep"
sleep 2
msg "${PURPLE}===${NOFORMAT} Release prep successful in $((SECONDS - PUB_STARTAT)) seconds."
else
msg "${RED}===${NOFORMAT} Missing -p flag, not running release prep"
fi

37 changes: 12 additions & 25 deletions release-publish.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Script description here.
Post-build release processing script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-v, --verbose Print script debug info
EOF
exit
Expand DownExpand Up@@ -63,34 +64,20 @@ parse_params() {
parse_params "$@"
setup_colors

readonly BLD_PUBLISH_DIRECTORY=buildscript-${BLD_RELEASE_VERSION-}
#script logic here

msg "=== Installing necessary packages"
apt update && apt install build-essential zip -y
readonly PUB_STARTAT=$SECONDS

cd /
msg "${BLUE}===${NOFORMAT} Installing zip package"

msg "=== Making directory ${BLD_PUBLISH_DIRECTORY-}"
mkdir -p "${BLD_PUBLISH_DIRECTORY-}"
apt-get update && apt-get install zip -y

msg "=== Copying files into ${BLD_PUBLISH_DIRECTORY-}"
cp -a app/* "${BLD_PUBLISH_DIRECTORY-}"
msg "${BLUE}===${NOFORMAT} Publishing to buildscript-${BLD_RELEASE_VERSION}.zip"

msg "=== Compressing files"
zip -q -r9 "buildscript-${BLD_RELEASE_VERSION-}.zip" "${BLD_PUBLISH_DIRECTORY-}"/
mkdir -p "/package" && \
cd /app && \
zip -q -r9 "/package/buildscript-${BLD_RELEASE_VERSION}.zip" "build.bash" && \
du -sh "/package/buildscript-${BLD_RELEASE_VERSION}.zip"

du -sch "${BLD_PUBLISH_DIRECTORY-}"/ "buildscript-${BLD_RELEASE_VERSION-}.zip"
msg "${PURPLE}===${NOFORMAT} Publish script complete in $((SECONDS - PUB_STARTAT)) seconds."

if [[ -n "${BLD_RELEASE_TOKEN-}" ]]; then
curl -L -O https://github.com/tfausak/github-release/releases/latest/download/github-release-linux.gz
gunzip github-release-linux.gz && chmod 700 github-release-linux && \
./github-release-linux upload \
--token "${BLD_RELEASE_TOKEN-}" \
--owner "${BLD_RELEASE_OWNER-}" \
--repo "${BLD_RELEASE_REPO-}" \
--tag "v${BLD_RELEASE_VERSION-}" \
--file "buildscript-${BLD_RELEASE_VERSION-}.zip" \
--name "buildscript-${BLD_RELEASE_VERSION-}.zip"
else
echo "=== No BLD_RELEASE_TOKEN configured, not pushing release artifacts to GitHub Releases"
fi
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,10 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build.bash -p

- uses: actions/upload-artifact@v4
with:
name: Buildscript
path: package/buildscript-*.zip
if-no-files-found: ignore

12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.3] - 2025-10-09

- Revert broken build changes
- Improve release-prep.bash and release-publish.bash scripts
- Change to manual deployment method
- Revise and streamline Dockerfile
- Add copy of release-publish script to Dockerfile

## [1.3.2] - 2025-09-17

Expand DownExpand Up@@ -49,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GitHub workflow `build.yml` to show how to call the script as a GitHub Action

[unreleased]: https://github.com/mcld/buildscript/compare/v1.3.0...HEAD
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.3.3]: https://github.com/mcld/buildscript/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/mcld/buildscript/compare/v1.3.0...v1.3.2
[1.3.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mcld/buildscript/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/mcld/buildscript/compare/v1.0.0...v1.0.1
Expand Down
73 changes: 41 additions & 32 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,60 @@
# prepare base image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

# get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy source
COPY . ./

# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown

# run dotnet restore
COPY ["buildscript/buildscript.csproj", "buildscript/"]
RUN dotnet restore "buildscript/buildscript.csproj"
# Restore packages
RUN dotnet restore

# copy source and build
COPY . .
WORKDIR "/src/buildscript"
RUN dotnet build "buildscript.csproj" -c Release -o /app/build
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0

# create publish image
FROM build AS publish
RUN dotnet publish "buildscript.csproj" -c Release -o /app/publish
# Publish release project
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/

# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"

# Copy actual build script
RUN cp /app/build.bash "/app/publish/"

# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish

# copy published app to final
FROM base AS final
WORKDIR /app

# Bring in metadata via --build-arg
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown

# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build script test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
LABEL branch=$BRANCH \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build scrip test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION

# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION

# Copy source
COPY --from=build "/app/publish/" .

COPY --from=publish /app/publish .
# Set entrypoint
ENTRYPOINT ["dotnet", "buildscript.dll"]
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ Options (all are optional):
- `-h, --help` - Print this help and exit
- `-v, --verbose` - Print script debug info
- `-df, --dockerfile` - Use the specified Dockerfile
- `-p, --publish` - Run the release-publish.bash script in the container(if it's present)
- `-p, --publish` - Run the release-prep and (in container) release-publish scripts (if present)
- `Docker tag` - Override the guessed Docker tag (the current directory) with this value if present

Environment variables (all are optional):
Expand Down
15 changes: 7 additions & 8 deletions build.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,8 @@ Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-df, --dockerfile Use the specified Dockerfile
-p, --publish Run the release-publish.bash script in the container (if it's present)
--no-color Do not use color codes in script output
-p, --publish Run release-prep.bash and (in container) release-publish.bash (if present)

Environment variables:

Expand All@@ -38,7 +39,7 @@ Environment variables:
- GHCR_PAT - optional - GitHub Container Registry Personal Access Token
- GHCR_USER - optional - username to log in to the GitHub Container Registry

Version 1.3.2 released 2025-09-17
Version 1.3.3 released 2025-10-09
EOF
exit
}
Expand DownExpand Up@@ -116,7 +117,7 @@ readonly SYSARCH

if [[ ${SYSARCH} = "i386" ]]; then
readonly ARCH="x86_32"
elif [[ ${SYSARCH} = "aarch64" ]]; then
elif [[ ${SYSARCH} = "aarch64" ]]; then
readonly ARCH="armv7"
else
readonly ARCH=${SYSARCH}
Expand DownExpand Up@@ -162,11 +163,11 @@ fi
if [[ $BLD_BRANCH = "develop"
|| $BLD_BRANCH = "main"
|| $BLD_BRANCH = "master"
|| $BLD_BRANCH = "test" ]]; then
|| $BLD_BRANCH = "test" ]]; then
BLD_DOCKER_TAG=$BLD_BRANCH
BLD_VERSION=${BLD_BRANCH}-${BLD_VERSION_DATE}
BLD_PUSH=true
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
BLD_RELEASE_VERSION=${BASH_REMATCH[1]}
BLD_DOCKER_TAG=v${BLD_RELEASE_VERSION}
BLD_VERSION=v${BLD_RELEASE_VERSION}
Expand DownExpand Up@@ -202,7 +203,7 @@ fi
if [[ $BLD_RELEASE = "true" && -x "release-prep.bash" ]]; then
msg "${BLUE}===${NOFORMAT} Running release preparation for version $BLD_RELEASE_VERSION"
#shellcheck disable=SC1091
./release-prep.bash
source release-prep.bash
msg "${GREEN}===${NOFORMAT} Release preparation script complete"
fi

Expand DownExpand Up@@ -311,15 +312,13 @@ if [[ $BLD_PUSH = true ]]; then
--entrypoint "/app/release-publish.bash" \
--env-file release.env \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
else
docker run -i \
--rm \
--entrypoint "/app/release-publish.bash" \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
fi
Expand Down
2 changes: 2 additions & 0 deletions buildscript.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.bash = build.bash
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
Dockerfile = Dockerfile
LICENSE.md = LICENSE.md
README.md = README.md
release-prep.bash = release-prep.bash
release-publish.bash = release-publish.bash
Expand Down
79 changes: 43 additions & 36 deletions release-prep.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,68 +7,75 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v]

Fake release prep script.
Pre-build release preparation script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-p Perform publish steps
-v, --verbose Print script debug info
EOF
exit
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
param=''

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
# default values of variables set from params
publish=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-p | --publish) publish=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

return 0
}

parse_params "$@"
setup_colors

# script logic here

msg "... release-prep.bash is preparing for release"
sleep 2
msg "... release-prep.bash has prepared for release."
readonly PUB_STARTAT=$SECONDS

if [[ publish -eq 1 ]]; then
msg "${BLUE}===${NOFORMAT} Performing publish release prep"
sleep 2
msg "${PURPLE}===${NOFORMAT} Release prep successful in $((SECONDS - PUB_STARTAT)) seconds."
else
msg "${RED}===${NOFORMAT} Missing -p flag, not running release prep"
fi

37 changes: 12 additions & 25 deletions release-publish.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Script description here.
Post-build release processing script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-v, --verbose Print script debug info
EOF
exit
Expand DownExpand Up@@ -63,34 +64,20 @@ parse_params() {
parse_params "$@"
setup_colors

readonly BLD_PUBLISH_DIRECTORY=buildscript-${BLD_RELEASE_VERSION-}
#script logic here

msg "=== Installing necessary packages"
apt update && apt install build-essential zip -y
readonly PUB_STARTAT=$SECONDS

cd /
msg "${BLUE}===${NOFORMAT} Installing zip package"

msg "=== Making directory ${BLD_PUBLISH_DIRECTORY-}"
mkdir -p "${BLD_PUBLISH_DIRECTORY-}"
apt-get update && apt-get install zip -y

msg "=== Copying files into ${BLD_PUBLISH_DIRECTORY-}"
cp -a app/* "${BLD_PUBLISH_DIRECTORY-}"
msg "${BLUE}===${NOFORMAT} Publishing to buildscript-${BLD_RELEASE_VERSION}.zip"

msg "=== Compressing files"
zip -q -r9 "buildscript-${BLD_RELEASE_VERSION-}.zip" "${BLD_PUBLISH_DIRECTORY-}"/
mkdir -p "/package" && \
cd /app && \
zip -q -r9 "/package/buildscript-${BLD_RELEASE_VERSION}.zip" "build.bash" && \
du -sh "/package/buildscript-${BLD_RELEASE_VERSION}.zip"

du -sch "${BLD_PUBLISH_DIRECTORY-}"/ "buildscript-${BLD_RELEASE_VERSION-}.zip"
msg "${PURPLE}===${NOFORMAT} Publish script complete in $((SECONDS - PUB_STARTAT)) seconds."

if [[ -n "${BLD_RELEASE_TOKEN-}" ]]; then
curl -L -O https://github.com/tfausak/github-release/releases/latest/download/github-release-linux.gz
gunzip github-release-linux.gz && chmod 700 github-release-linux && \
./github-release-linux upload \
--token "${BLD_RELEASE_TOKEN-}" \
--owner "${BLD_RELEASE_OWNER-}" \
--repo "${BLD_RELEASE_REPO-}" \
--tag "v${BLD_RELEASE_VERSION-}" \
--file "buildscript-${BLD_RELEASE_VERSION-}.zip" \
--name "buildscript-${BLD_RELEASE_VERSION-}.zip"
else
echo "=== No BLD_RELEASE_TOKEN configured, not pushing release artifacts to GitHub Releases"
fi
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,10 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build.bash -p

- uses: actions/upload-artifact@v4
with:
name: Buildscript
path: package/buildscript-*.zip
if-no-files-found: ignore

12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.3] - 2025-10-09

- Revert broken build changes
- Improve release-prep.bash and release-publish.bash scripts
- Change to manual deployment method
- Revise and streamline Dockerfile
- Add copy of release-publish script to Dockerfile

## [1.3.2] - 2025-09-17

Expand DownExpand Up@@ -49,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GitHub workflow `build.yml` to show how to call the script as a GitHub Action

[unreleased]: https://github.com/mcld/buildscript/compare/v1.3.0...HEAD
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.3.3]: https://github.com/mcld/buildscript/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/mcld/buildscript/compare/v1.3.0...v1.3.2
[1.3.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mcld/buildscript/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/mcld/buildscript/compare/v1.0.0...v1.0.1
Expand Down
73 changes: 41 additions & 32 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,60 @@
# prepare base image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

# get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy source
COPY . ./

# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown

# run dotnet restore
COPY ["buildscript/buildscript.csproj", "buildscript/"]
RUN dotnet restore "buildscript/buildscript.csproj"
# Restore packages
RUN dotnet restore

# copy source and build
COPY . .
WORKDIR "/src/buildscript"
RUN dotnet build "buildscript.csproj" -c Release -o /app/build
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0

# create publish image
FROM build AS publish
RUN dotnet publish "buildscript.csproj" -c Release -o /app/publish
# Publish release project
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/

# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"

# Copy actual build script
RUN cp /app/build.bash "/app/publish/"

# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish

# copy published app to final
FROM base AS final
WORKDIR /app

# Bring in metadata via --build-arg
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown

# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build script test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
LABEL branch=$BRANCH \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build scrip test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION

# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION

# Copy source
COPY --from=build "/app/publish/" .

COPY --from=publish /app/publish .
# Set entrypoint
ENTRYPOINT ["dotnet", "buildscript.dll"]
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ Options (all are optional):
- `-h, --help` - Print this help and exit
- `-v, --verbose` - Print script debug info
- `-df, --dockerfile` - Use the specified Dockerfile
- `-p, --publish` - Run the release-publish.bash script in the container(if it's present)
- `-p, --publish` - Run the release-prep and (in container) release-publish scripts (if present)
- `Docker tag` - Override the guessed Docker tag (the current directory) with this value if present

Environment variables (all are optional):
Expand Down
15 changes: 7 additions & 8 deletions build.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,8 @@ Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-df, --dockerfile Use the specified Dockerfile
-p, --publish Run the release-publish.bash script in the container (if it's present)
--no-color Do not use color codes in script output
-p, --publish Run release-prep.bash and (in container) release-publish.bash (if present)

Environment variables:

Expand All@@ -38,7 +39,7 @@ Environment variables:
- GHCR_PAT - optional - GitHub Container Registry Personal Access Token
- GHCR_USER - optional - username to log in to the GitHub Container Registry

Version 1.3.2 released 2025-09-17
Version 1.3.3 released 2025-10-09
EOF
exit
}
Expand DownExpand Up@@ -116,7 +117,7 @@ readonly SYSARCH

if [[ ${SYSARCH} = "i386" ]]; then
readonly ARCH="x86_32"
elif [[ ${SYSARCH} = "aarch64" ]]; then
elif [[ ${SYSARCH} = "aarch64" ]]; then
readonly ARCH="armv7"
else
readonly ARCH=${SYSARCH}
Expand DownExpand Up@@ -162,11 +163,11 @@ fi
if [[ $BLD_BRANCH = "develop"
|| $BLD_BRANCH = "main"
|| $BLD_BRANCH = "master"
|| $BLD_BRANCH = "test" ]]; then
|| $BLD_BRANCH = "test" ]]; then
BLD_DOCKER_TAG=$BLD_BRANCH
BLD_VERSION=${BLD_BRANCH}-${BLD_VERSION_DATE}
BLD_PUSH=true
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
BLD_RELEASE_VERSION=${BASH_REMATCH[1]}
BLD_DOCKER_TAG=v${BLD_RELEASE_VERSION}
BLD_VERSION=v${BLD_RELEASE_VERSION}
Expand DownExpand Up@@ -202,7 +203,7 @@ fi
if [[ $BLD_RELEASE = "true" && -x "release-prep.bash" ]]; then
msg "${BLUE}===${NOFORMAT} Running release preparation for version $BLD_RELEASE_VERSION"
#shellcheck disable=SC1091
./release-prep.bash
source release-prep.bash
msg "${GREEN}===${NOFORMAT} Release preparation script complete"
fi

Expand DownExpand Up@@ -311,15 +312,13 @@ if [[ $BLD_PUSH = true ]]; then
--entrypoint "/app/release-publish.bash" \
--env-file release.env \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
else
docker run -i \
--rm \
--entrypoint "/app/release-publish.bash" \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
fi
Expand Down
2 changes: 2 additions & 0 deletions buildscript.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.bash = build.bash
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
Dockerfile = Dockerfile
LICENSE.md = LICENSE.md
README.md = README.md
release-prep.bash = release-prep.bash
release-publish.bash = release-publish.bash
Expand Down
79 changes: 43 additions & 36 deletions release-prep.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,68 +7,75 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v]

Fake release prep script.
Pre-build release preparation script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-p Perform publish steps
-v, --verbose Print script debug info
EOF
exit
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
param=''

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
# default values of variables set from params
publish=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-p | --publish) publish=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

return 0
}

parse_params "$@"
setup_colors

# script logic here

msg "... release-prep.bash is preparing for release"
sleep 2
msg "... release-prep.bash has prepared for release."
readonly PUB_STARTAT=$SECONDS

if [[ publish -eq 1 ]]; then
msg "${BLUE}===${NOFORMAT} Performing publish release prep"
sleep 2
msg "${PURPLE}===${NOFORMAT} Release prep successful in $((SECONDS - PUB_STARTAT)) seconds."
else
msg "${RED}===${NOFORMAT} Missing -p flag, not running release prep"
fi

37 changes: 12 additions & 25 deletions release-publish.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Script description here.
Post-build release processing script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-v, --verbose Print script debug info
EOF
exit
Expand DownExpand Up@@ -63,34 +64,20 @@ parse_params() {
parse_params "$@"
setup_colors

readonly BLD_PUBLISH_DIRECTORY=buildscript-${BLD_RELEASE_VERSION-}
#script logic here

msg "=== Installing necessary packages"
apt update && apt install build-essential zip -y
readonly PUB_STARTAT=$SECONDS

cd /
msg "${BLUE}===${NOFORMAT} Installing zip package"

msg "=== Making directory ${BLD_PUBLISH_DIRECTORY-}"
mkdir -p "${BLD_PUBLISH_DIRECTORY-}"
apt-get update && apt-get install zip -y

msg "=== Copying files into ${BLD_PUBLISH_DIRECTORY-}"
cp -a app/* "${BLD_PUBLISH_DIRECTORY-}"
msg "${BLUE}===${NOFORMAT} Publishing to buildscript-${BLD_RELEASE_VERSION}.zip"

msg "=== Compressing files"
zip -q -r9 "buildscript-${BLD_RELEASE_VERSION-}.zip" "${BLD_PUBLISH_DIRECTORY-}"/
mkdir -p "/package" && \
cd /app && \
zip -q -r9 "/package/buildscript-${BLD_RELEASE_VERSION}.zip" "build.bash" && \
du -sh "/package/buildscript-${BLD_RELEASE_VERSION}.zip"

du -sch "${BLD_PUBLISH_DIRECTORY-}"/ "buildscript-${BLD_RELEASE_VERSION-}.zip"
msg "${PURPLE}===${NOFORMAT} Publish script complete in $((SECONDS - PUB_STARTAT)) seconds."

if [[ -n "${BLD_RELEASE_TOKEN-}" ]]; then
curl -L -O https://github.com/tfausak/github-release/releases/latest/download/github-release-linux.gz
gunzip github-release-linux.gz && chmod 700 github-release-linux && \
./github-release-linux upload \
--token "${BLD_RELEASE_TOKEN-}" \
--owner "${BLD_RELEASE_OWNER-}" \
--repo "${BLD_RELEASE_REPO-}" \
--tag "v${BLD_RELEASE_VERSION-}" \
--file "buildscript-${BLD_RELEASE_VERSION-}.zip" \
--name "buildscript-${BLD_RELEASE_VERSION-}.zip"
else
echo "=== No BLD_RELEASE_TOKEN configured, not pushing release artifacts to GitHub Releases"
fi
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,10 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build.bash -p

- uses: actions/upload-artifact@v4
with:
name: Buildscript
path: package/buildscript-*.zip
if-no-files-found: ignore

12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.3] - 2025-10-09

- Revert broken build changes
- Improve release-prep.bash and release-publish.bash scripts
- Change to manual deployment method
- Revise and streamline Dockerfile
- Add copy of release-publish script to Dockerfile

## [1.3.2] - 2025-09-17

Expand DownExpand Up@@ -49,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GitHub workflow `build.yml` to show how to call the script as a GitHub Action

[unreleased]: https://github.com/mcld/buildscript/compare/v1.3.0...HEAD
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.3.3]: https://github.com/mcld/buildscript/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/mcld/buildscript/compare/v1.3.0...v1.3.2
[1.3.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mcld/buildscript/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/mcld/buildscript/compare/v1.0.0...v1.0.1
Expand Down
73 changes: 41 additions & 32 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,60 @@
# prepare base image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

# get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy source
COPY . ./

# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown

# run dotnet restore
COPY ["buildscript/buildscript.csproj", "buildscript/"]
RUN dotnet restore "buildscript/buildscript.csproj"
# Restore packages
RUN dotnet restore

# copy source and build
COPY . .
WORKDIR "/src/buildscript"
RUN dotnet build "buildscript.csproj" -c Release -o /app/build
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0

# create publish image
FROM build AS publish
RUN dotnet publish "buildscript.csproj" -c Release -o /app/publish
# Publish release project
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/

# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"

# Copy actual build script
RUN cp /app/build.bash "/app/publish/"

# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish

# copy published app to final
FROM base AS final
WORKDIR /app

# Bring in metadata via --build-arg
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown

# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build script test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
LABEL branch=$BRANCH \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build scrip test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION

# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION

# Copy source
COPY --from=build "/app/publish/" .

COPY --from=publish /app/publish .
# Set entrypoint
ENTRYPOINT ["dotnet", "buildscript.dll"]
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ Options (all are optional):
- `-h, --help` - Print this help and exit
- `-v, --verbose` - Print script debug info
- `-df, --dockerfile` - Use the specified Dockerfile
- `-p, --publish` - Run the release-publish.bash script in the container(if it's present)
- `-p, --publish` - Run the release-prep and (in container) release-publish scripts (if present)
- `Docker tag` - Override the guessed Docker tag (the current directory) with this value if present

Environment variables (all are optional):
Expand Down
15 changes: 7 additions & 8 deletions build.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,8 @@ Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-df, --dockerfile Use the specified Dockerfile
-p, --publish Run the release-publish.bash script in the container (if it's present)
--no-color Do not use color codes in script output
-p, --publish Run release-prep.bash and (in container) release-publish.bash (if present)

Environment variables:

Expand All@@ -38,7 +39,7 @@ Environment variables:
- GHCR_PAT - optional - GitHub Container Registry Personal Access Token
- GHCR_USER - optional - username to log in to the GitHub Container Registry

Version 1.3.2 released 2025-09-17
Version 1.3.3 released 2025-10-09
EOF
exit
}
Expand DownExpand Up@@ -116,7 +117,7 @@ readonly SYSARCH

if [[ ${SYSARCH} = "i386" ]]; then
readonly ARCH="x86_32"
elif [[ ${SYSARCH} = "aarch64" ]]; then
elif [[ ${SYSARCH} = "aarch64" ]]; then
readonly ARCH="armv7"
else
readonly ARCH=${SYSARCH}
Expand DownExpand Up@@ -162,11 +163,11 @@ fi
if [[ $BLD_BRANCH = "develop"
|| $BLD_BRANCH = "main"
|| $BLD_BRANCH = "master"
|| $BLD_BRANCH = "test" ]]; then
|| $BLD_BRANCH = "test" ]]; then
BLD_DOCKER_TAG=$BLD_BRANCH
BLD_VERSION=${BLD_BRANCH}-${BLD_VERSION_DATE}
BLD_PUSH=true
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
BLD_RELEASE_VERSION=${BASH_REMATCH[1]}
BLD_DOCKER_TAG=v${BLD_RELEASE_VERSION}
BLD_VERSION=v${BLD_RELEASE_VERSION}
Expand DownExpand Up@@ -202,7 +203,7 @@ fi
if [[ $BLD_RELEASE = "true" && -x "release-prep.bash" ]]; then
msg "${BLUE}===${NOFORMAT} Running release preparation for version $BLD_RELEASE_VERSION"
#shellcheck disable=SC1091
./release-prep.bash
source release-prep.bash
msg "${GREEN}===${NOFORMAT} Release preparation script complete"
fi

Expand DownExpand Up@@ -311,15 +312,13 @@ if [[ $BLD_PUSH = true ]]; then
--entrypoint "/app/release-publish.bash" \
--env-file release.env \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
else
docker run -i \
--rm \
--entrypoint "/app/release-publish.bash" \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
fi
Expand Down
2 changes: 2 additions & 0 deletions buildscript.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.bash = build.bash
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
Dockerfile = Dockerfile
LICENSE.md = LICENSE.md
README.md = README.md
release-prep.bash = release-prep.bash
release-publish.bash = release-publish.bash
Expand Down
79 changes: 43 additions & 36 deletions release-prep.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,68 +7,75 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v]

Fake release prep script.
Pre-build release preparation script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-p Perform publish steps
-v, --verbose Print script debug info
EOF
exit
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
param=''

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
# default values of variables set from params
publish=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-p | --publish) publish=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

return 0
}

parse_params "$@"
setup_colors

# script logic here

msg "... release-prep.bash is preparing for release"
sleep 2
msg "... release-prep.bash has prepared for release."
readonly PUB_STARTAT=$SECONDS

if [[ publish -eq 1 ]]; then
msg "${BLUE}===${NOFORMAT} Performing publish release prep"
sleep 2
msg "${PURPLE}===${NOFORMAT} Release prep successful in $((SECONDS - PUB_STARTAT)) seconds."
else
msg "${RED}===${NOFORMAT} Missing -p flag, not running release prep"
fi

37 changes: 12 additions & 25 deletions release-publish.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Script description here.
Post-build release processing script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-v, --verbose Print script debug info
EOF
exit
Expand DownExpand Up@@ -63,34 +64,20 @@ parse_params() {
parse_params "$@"
setup_colors

readonly BLD_PUBLISH_DIRECTORY=buildscript-${BLD_RELEASE_VERSION-}
#script logic here

msg "=== Installing necessary packages"
apt update && apt install build-essential zip -y
readonly PUB_STARTAT=$SECONDS

cd /
msg "${BLUE}===${NOFORMAT} Installing zip package"

msg "=== Making directory ${BLD_PUBLISH_DIRECTORY-}"
mkdir -p "${BLD_PUBLISH_DIRECTORY-}"
apt-get update && apt-get install zip -y

msg "=== Copying files into ${BLD_PUBLISH_DIRECTORY-}"
cp -a app/* "${BLD_PUBLISH_DIRECTORY-}"
msg "${BLUE}===${NOFORMAT} Publishing to buildscript-${BLD_RELEASE_VERSION}.zip"

msg "=== Compressing files"
zip -q -r9 "buildscript-${BLD_RELEASE_VERSION-}.zip" "${BLD_PUBLISH_DIRECTORY-}"/
mkdir -p "/package" && \
cd /app && \
zip -q -r9 "/package/buildscript-${BLD_RELEASE_VERSION}.zip" "build.bash" && \
du -sh "/package/buildscript-${BLD_RELEASE_VERSION}.zip"

du -sch "${BLD_PUBLISH_DIRECTORY-}"/ "buildscript-${BLD_RELEASE_VERSION-}.zip"
msg "${PURPLE}===${NOFORMAT} Publish script complete in $((SECONDS - PUB_STARTAT)) seconds."

if [[ -n "${BLD_RELEASE_TOKEN-}" ]]; then
curl -L -O https://github.com/tfausak/github-release/releases/latest/download/github-release-linux.gz
gunzip github-release-linux.gz && chmod 700 github-release-linux && \
./github-release-linux upload \
--token "${BLD_RELEASE_TOKEN-}" \
--owner "${BLD_RELEASE_OWNER-}" \
--repo "${BLD_RELEASE_REPO-}" \
--tag "v${BLD_RELEASE_VERSION-}" \
--file "buildscript-${BLD_RELEASE_VERSION-}.zip" \
--name "buildscript-${BLD_RELEASE_VERSION-}.zip"
else
echo "=== No BLD_RELEASE_TOKEN configured, not pushing release artifacts to GitHub Releases"
fi
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,10 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build.bash -p

- uses: actions/upload-artifact@v4
with:
name: Buildscript
path: package/buildscript-*.zip
if-no-files-found: ignore

12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.3] - 2025-10-09

- Revert broken build changes
- Improve release-prep.bash and release-publish.bash scripts
- Change to manual deployment method
- Revise and streamline Dockerfile
- Add copy of release-publish script to Dockerfile

## [1.3.2] - 2025-09-17

Expand DownExpand Up@@ -49,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GitHub workflow `build.yml` to show how to call the script as a GitHub Action

[unreleased]: https://github.com/mcld/buildscript/compare/v1.3.0...HEAD
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.3.3]: https://github.com/mcld/buildscript/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/mcld/buildscript/compare/v1.3.0...v1.3.2
[1.3.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mcld/buildscript/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/mcld/buildscript/compare/v1.0.0...v1.0.1
Expand Down
73 changes: 41 additions & 32 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,60 @@
# prepare base image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

# get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy source
COPY . ./

# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown

# run dotnet restore
COPY ["buildscript/buildscript.csproj", "buildscript/"]
RUN dotnet restore "buildscript/buildscript.csproj"
# Restore packages
RUN dotnet restore

# copy source and build
COPY . .
WORKDIR "/src/buildscript"
RUN dotnet build "buildscript.csproj" -c Release -o /app/build
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0

# create publish image
FROM build AS publish
RUN dotnet publish "buildscript.csproj" -c Release -o /app/publish
# Publish release project
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/

# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"

# Copy actual build script
RUN cp /app/build.bash "/app/publish/"

# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish

# copy published app to final
FROM base AS final
WORKDIR /app

# Bring in metadata via --build-arg
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown

# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build script test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
LABEL branch=$BRANCH \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build scrip test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION

# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION

# Copy source
COPY --from=build "/app/publish/" .

COPY --from=publish /app/publish .
# Set entrypoint
ENTRYPOINT ["dotnet", "buildscript.dll"]
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ Options (all are optional):
- `-h, --help` - Print this help and exit
- `-v, --verbose` - Print script debug info
- `-df, --dockerfile` - Use the specified Dockerfile
- `-p, --publish` - Run the release-publish.bash script in the container(if it's present)
- `-p, --publish` - Run the release-prep and (in container) release-publish scripts (if present)
- `Docker tag` - Override the guessed Docker tag (the current directory) with this value if present

Environment variables (all are optional):
Expand Down
15 changes: 7 additions & 8 deletions build.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,8 @@ Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-df, --dockerfile Use the specified Dockerfile
-p, --publish Run the release-publish.bash script in the container (if it's present)
--no-color Do not use color codes in script output
-p, --publish Run release-prep.bash and (in container) release-publish.bash (if present)

Environment variables:

Expand All@@ -38,7 +39,7 @@ Environment variables:
- GHCR_PAT - optional - GitHub Container Registry Personal Access Token
- GHCR_USER - optional - username to log in to the GitHub Container Registry

Version 1.3.2 released 2025-09-17
Version 1.3.3 released 2025-10-09
EOF
exit
}
Expand DownExpand Up@@ -116,7 +117,7 @@ readonly SYSARCH

if [[ ${SYSARCH} = "i386" ]]; then
readonly ARCH="x86_32"
elif [[ ${SYSARCH} = "aarch64" ]]; then
elif [[ ${SYSARCH} = "aarch64" ]]; then
readonly ARCH="armv7"
else
readonly ARCH=${SYSARCH}
Expand DownExpand Up@@ -162,11 +163,11 @@ fi
if [[ $BLD_BRANCH = "develop"
|| $BLD_BRANCH = "main"
|| $BLD_BRANCH = "master"
|| $BLD_BRANCH = "test" ]]; then
|| $BLD_BRANCH = "test" ]]; then
BLD_DOCKER_TAG=$BLD_BRANCH
BLD_VERSION=${BLD_BRANCH}-${BLD_VERSION_DATE}
BLD_PUSH=true
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
BLD_RELEASE_VERSION=${BASH_REMATCH[1]}
BLD_DOCKER_TAG=v${BLD_RELEASE_VERSION}
BLD_VERSION=v${BLD_RELEASE_VERSION}
Expand DownExpand Up@@ -202,7 +203,7 @@ fi
if [[ $BLD_RELEASE = "true" && -x "release-prep.bash" ]]; then
msg "${BLUE}===${NOFORMAT} Running release preparation for version $BLD_RELEASE_VERSION"
#shellcheck disable=SC1091
./release-prep.bash
source release-prep.bash
msg "${GREEN}===${NOFORMAT} Release preparation script complete"
fi

Expand DownExpand Up@@ -311,15 +312,13 @@ if [[ $BLD_PUSH = true ]]; then
--entrypoint "/app/release-publish.bash" \
--env-file release.env \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
else
docker run -i \
--rm \
--entrypoint "/app/release-publish.bash" \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
fi
Expand Down
2 changes: 2 additions & 0 deletions buildscript.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.bash = build.bash
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
Dockerfile = Dockerfile
LICENSE.md = LICENSE.md
README.md = README.md
release-prep.bash = release-prep.bash
release-publish.bash = release-publish.bash
Expand Down
79 changes: 43 additions & 36 deletions release-prep.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,68 +7,75 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v]

Fake release prep script.
Pre-build release preparation script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-p Perform publish steps
-v, --verbose Print script debug info
EOF
exit
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
param=''

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
# default values of variables set from params
publish=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-p | --publish) publish=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

return 0
}

parse_params "$@"
setup_colors

# script logic here

msg "... release-prep.bash is preparing for release"
sleep 2
msg "... release-prep.bash has prepared for release."
readonly PUB_STARTAT=$SECONDS

if [[ publish -eq 1 ]]; then
msg "${BLUE}===${NOFORMAT} Performing publish release prep"
sleep 2
msg "${PURPLE}===${NOFORMAT} Release prep successful in $((SECONDS - PUB_STARTAT)) seconds."
else
msg "${RED}===${NOFORMAT} Missing -p flag, not running release prep"
fi

37 changes: 12 additions & 25 deletions release-publish.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Script description here.
Post-build release processing script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-v, --verbose Print script debug info
EOF
exit
Expand DownExpand Up@@ -63,34 +64,20 @@ parse_params() {
parse_params "$@"
setup_colors

readonly BLD_PUBLISH_DIRECTORY=buildscript-${BLD_RELEASE_VERSION-}
#script logic here

msg "=== Installing necessary packages"
apt update && apt install build-essential zip -y
readonly PUB_STARTAT=$SECONDS

cd /
msg "${BLUE}===${NOFORMAT} Installing zip package"

msg "=== Making directory ${BLD_PUBLISH_DIRECTORY-}"
mkdir -p "${BLD_PUBLISH_DIRECTORY-}"
apt-get update && apt-get install zip -y

msg "=== Copying files into ${BLD_PUBLISH_DIRECTORY-}"
cp -a app/* "${BLD_PUBLISH_DIRECTORY-}"
msg "${BLUE}===${NOFORMAT} Publishing to buildscript-${BLD_RELEASE_VERSION}.zip"

msg "=== Compressing files"
zip -q -r9 "buildscript-${BLD_RELEASE_VERSION-}.zip" "${BLD_PUBLISH_DIRECTORY-}"/
mkdir -p "/package" && \
cd /app && \
zip -q -r9 "/package/buildscript-${BLD_RELEASE_VERSION}.zip" "build.bash" && \
du -sh "/package/buildscript-${BLD_RELEASE_VERSION}.zip"

du -sch "${BLD_PUBLISH_DIRECTORY-}"/ "buildscript-${BLD_RELEASE_VERSION-}.zip"
msg "${PURPLE}===${NOFORMAT} Publish script complete in $((SECONDS - PUB_STARTAT)) seconds."

if [[ -n "${BLD_RELEASE_TOKEN-}" ]]; then
curl -L -O https://github.com/tfausak/github-release/releases/latest/download/github-release-linux.gz
gunzip github-release-linux.gz && chmod 700 github-release-linux && \
./github-release-linux upload \
--token "${BLD_RELEASE_TOKEN-}" \
--owner "${BLD_RELEASE_OWNER-}" \
--repo "${BLD_RELEASE_REPO-}" \
--tag "v${BLD_RELEASE_VERSION-}" \
--file "buildscript-${BLD_RELEASE_VERSION-}.zip" \
--name "buildscript-${BLD_RELEASE_VERSION-}.zip"
else
echo "=== No BLD_RELEASE_TOKEN configured, not pushing release artifacts to GitHub Releases"
fi
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,3 +22,10 @@ jobs:
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./build.bash -p

- uses: actions/upload-artifact@v4
with:
name: Buildscript
path: package/buildscript-*.zip
if-no-files-found: ignore

12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.3.3] - 2025-10-09

- Revert broken build changes
- Improve release-prep.bash and release-publish.bash scripts
- Change to manual deployment method
- Revise and streamline Dockerfile
- Add copy of release-publish script to Dockerfile

## [1.3.2] - 2025-09-17

Expand DownExpand Up@@ -49,7 +55,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GitHub workflow `build.yml` to show how to call the script as a GitHub Action

[unreleased]: https://github.com/mcld/buildscript/compare/v1.3.0...HEAD
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.3.3]: https://github.com/mcld/buildscript/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/mcld/buildscript/compare/v1.3.0...v1.3.2
[1.3.0]: https://github.com/mcld/buildscript/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/mcld/buildscript/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/mcld/buildscript/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/mcld/buildscript/compare/v1.0.0...v1.0.1
Expand Down
73 changes: 41 additions & 32 deletions Dockerfile
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,60 @@
# prepare base image
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
# Get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

WORKDIR /app

# get build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Copy source
COPY . ./

# Bring in metadata via --build-arg for build
ARG IMAGE_VERSION=unknown

# run dotnet restore
COPY ["buildscript/buildscript.csproj", "buildscript/"]
RUN dotnet restore "buildscript/buildscript.csproj"
# Restore packages
RUN dotnet restore

# copy source and build
COPY . .
WORKDIR "/src/buildscript"
RUN dotnet build "buildscript.csproj" -c Release -o /app/build
# Build project and run tests
RUN dotnet test -v m /property:WarningLevel=0

# create publish image
FROM build AS publish
RUN dotnet publish "buildscript.csproj" -c Release -o /app/publish
# Publish release project
RUN dotnet publish -v m /property:WarningLevel=0 -c Release --property:PublishDir=/app/publish/

# Copy release-publish.bash script
RUN cp /app/release-publish.bash "/app/publish/"

# Copy actual build script
RUN cp /app/build.bash "/app/publish/"

# Get runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS publish

# copy published app to final
FROM base AS final
WORKDIR /app

# Bring in metadata via --build-arg
# Bring in metadata via --build-arg to publish
ARG BRANCH=unknown
ARG IMAGE_CREATED=unknown
ARG IMAGE_REVISION=unknown
ARG IMAGE_VERSION=unknown

# Configure image labels
LABEL branch=$branch \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build script test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION
LABEL branch=$BRANCH \
maintainer="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.authors="Maricopa County Library District developers <development@mcldaz.org>" \
org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.description="Build script test project" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.source="https://github.com/MCLD/buildscript" \
org.opencontainers.image.title="Build scrip test project" \
org.opencontainers.image.vendor="Maricopa County Library District" \
org.opencontainers.image.version=$IMAGE_VERSION

# Default image environment variable settings
ENV org.opencontainers.image.created=$IMAGE_CREATED \
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION
org.opencontainers.image.revision=$IMAGE_REVISION \
org.opencontainers.image.version=$IMAGE_VERSION

# Copy source
COPY --from=build "/app/publish/" .

COPY --from=publish /app/publish .
# Set entrypoint
ENTRYPOINT ["dotnet", "buildscript.dll"]
2 changes: 1 addition & 1 deletion README.md
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ Options (all are optional):
- `-h, --help` - Print this help and exit
- `-v, --verbose` - Print script debug info
- `-df, --dockerfile` - Use the specified Dockerfile
- `-p, --publish` - Run the release-publish.bash script in the container(if it's present)
- `-p, --publish` - Run the release-prep and (in container) release-publish scripts (if present)
- `Docker tag` - Override the guessed Docker tag (the current directory) with this value if present

Environment variables (all are optional):
Expand Down
15 changes: 7 additions & 8 deletions build.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,7 +23,8 @@ Available options:
-h, --help Print this help and exit
-v, --verbose Print script debug info
-df, --dockerfile Use the specified Dockerfile
-p, --publish Run the release-publish.bash script in the container (if it's present)
--no-color Do not use color codes in script output
-p, --publish Run release-prep.bash and (in container) release-publish.bash (if present)

Environment variables:

Expand All@@ -38,7 +39,7 @@ Environment variables:
- GHCR_PAT - optional - GitHub Container Registry Personal Access Token
- GHCR_USER - optional - username to log in to the GitHub Container Registry

Version 1.3.2 released 2025-09-17
Version 1.3.3 released 2025-10-09
EOF
exit
}
Expand DownExpand Up@@ -116,7 +117,7 @@ readonly SYSARCH

if [[ ${SYSARCH} = "i386" ]]; then
readonly ARCH="x86_32"
elif [[ ${SYSARCH} = "aarch64" ]]; then
elif [[ ${SYSARCH} = "aarch64" ]]; then
readonly ARCH="armv7"
else
readonly ARCH=${SYSARCH}
Expand DownExpand Up@@ -162,11 +163,11 @@ fi
if [[ $BLD_BRANCH = "develop"
|| $BLD_BRANCH = "main"
|| $BLD_BRANCH = "master"
|| $BLD_BRANCH = "test" ]]; then
|| $BLD_BRANCH = "test" ]]; then
BLD_DOCKER_TAG=$BLD_BRANCH
BLD_VERSION=${BLD_BRANCH}-${BLD_VERSION_DATE}
BLD_PUSH=true
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
elif [[ "$BLD_BRANCH" =~ release/([0-9]+\.[0-9]+\.[0-9]+.*) ]]; then
BLD_RELEASE_VERSION=${BASH_REMATCH[1]}
BLD_DOCKER_TAG=v${BLD_RELEASE_VERSION}
BLD_VERSION=v${BLD_RELEASE_VERSION}
Expand DownExpand Up@@ -202,7 +203,7 @@ fi
if [[ $BLD_RELEASE = "true" && -x "release-prep.bash" ]]; then
msg "${BLUE}===${NOFORMAT} Running release preparation for version $BLD_RELEASE_VERSION"
#shellcheck disable=SC1091
./release-prep.bash
source release-prep.bash
msg "${GREEN}===${NOFORMAT} Release preparation script complete"
fi

Expand DownExpand Up@@ -311,15 +312,13 @@ if [[ $BLD_PUSH = true ]]; then
--entrypoint "/app/release-publish.bash" \
--env-file release.env \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
else
docker run -i \
--rm \
--entrypoint "/app/release-publish.bash" \
-e BLD_RELEASE_VERSION="$BLD_RELEASE_VERSION" \
-v "${PWD}/:/app" \
-v "${PWD}/package:/package" \
"$BLD_FULL_DOCKER_IMAGE"
fi
Expand Down
2 changes: 2 additions & 0 deletions buildscript.sln
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,8 +10,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.gitignore = .gitignore
azure-pipelines.yml = azure-pipelines.yml
build.bash = build.bash
CHANGELOG.md = CHANGELOG.md
.github\workflows\ci.yml = .github\workflows\ci.yml
Dockerfile = Dockerfile
LICENSE.md = LICENSE.md
README.md = README.md
release-prep.bash = release-prep.bash
release-publish.bash = release-publish.bash
Expand Down
79 changes: 43 additions & 36 deletions release-prep.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,68 +7,75 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)

usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v]

Fake release prep script.
Pre-build release preparation script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-p Perform publish steps
-v, --verbose Print script debug info
EOF
exit
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
param=''

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

args=("$@")

return 0
# default values of variables set from params
publish=0

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-p | --publish) publish=1 ;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

return 0
}

parse_params "$@"
setup_colors

# script logic here

msg "... release-prep.bash is preparing for release"
sleep 2
msg "... release-prep.bash has prepared for release."
readonly PUB_STARTAT=$SECONDS

if [[ publish -eq 1 ]]; then
msg "${BLUE}===${NOFORMAT} Performing publish release prep"
sleep 2
msg "${PURPLE}===${NOFORMAT} Release prep successful in $((SECONDS - PUB_STARTAT)) seconds."
else
msg "${RED}===${NOFORMAT} Missing -p flag, not running release prep"
fi

37 changes: 12 additions & 25 deletions release-publish.bash
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]

Script description here.
Post-build release processing script

Available options:

-h, --help Print this help and exit
--no-color Do not use color codes in script output
-v, --verbose Print script debug info
EOF
exit
Expand DownExpand Up@@ -63,34 +64,20 @@ parse_params() {
parse_params "$@"
setup_colors

readonly BLD_PUBLISH_DIRECTORY=buildscript-${BLD_RELEASE_VERSION-}
#script logic here

msg "=== Installing necessary packages"
apt update && apt install build-essential zip -y
readonly PUB_STARTAT=$SECONDS

cd /
msg "${BLUE}===${NOFORMAT} Installing zip package"

msg "=== Making directory ${BLD_PUBLISH_DIRECTORY-}"
mkdir -p "${BLD_PUBLISH_DIRECTORY-}"
apt-get update && apt-get install zip -y

msg "=== Copying files into ${BLD_PUBLISH_DIRECTORY-}"
cp -a app/* "${BLD_PUBLISH_DIRECTORY-}"
msg "${BLUE}===${NOFORMAT} Publishing to buildscript-${BLD_RELEASE_VERSION}.zip"

msg "=== Compressing files"
zip -q -r9 "buildscript-${BLD_RELEASE_VERSION-}.zip" "${BLD_PUBLISH_DIRECTORY-}"/
mkdir -p "/package" && \
cd /app && \
zip -q -r9 "/package/buildscript-${BLD_RELEASE_VERSION}.zip" "build.bash" && \
du -sh "/package/buildscript-${BLD_RELEASE_VERSION}.zip"

du -sch "${BLD_PUBLISH_DIRECTORY-}"/ "buildscript-${BLD_RELEASE_VERSION-}.zip"
msg "${PURPLE}===${NOFORMAT} Publish script complete in $((SECONDS - PUB_STARTAT)) seconds."

if [[ -n "${BLD_RELEASE_TOKEN-}" ]]; then
curl -L -O https://github.com/tfausak/github-release/releases/latest/download/github-release-linux.gz
gunzip github-release-linux.gz && chmod 700 github-release-linux && \
./github-release-linux upload \
--token "${BLD_RELEASE_TOKEN-}" \
--owner "${BLD_RELEASE_OWNER-}" \
--repo "${BLD_RELEASE_REPO-}" \
--tag "v${BLD_RELEASE_VERSION-}" \
--file "buildscript-${BLD_RELEASE_VERSION-}.zip" \
--name "buildscript-${BLD_RELEASE_VERSION-}.zip"
else
echo "=== No BLD_RELEASE_TOKEN configured, not pushing release artifacts to GitHub Releases"
fi