From 8ab3ec76ed920a7f5a048be10eb124aec5d4b2ad Mon Sep 17 00:00:00 2001 From: Harald Nagel Date: Thu, 9 Oct 2025 14:45:07 -0700 Subject: [PATCH] Changes for v1.3.3 --- .github/workflows/ci.yml | 7 ++++ CHANGELOG.md | 12 +++++- Dockerfile | 73 +++++++++++++++++++++---------------- README.md | 2 +- build.bash | 15 ++++---- buildscript.sln | 2 + release-prep.bash | 79 ++++++++++++++++++++++------------------ release-publish.bash | 37 ++++++------------- 8 files changed, 123 insertions(+), 104 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 10c1143..642390f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 + diff --git a/CHANGELOG.md b/CHANGELOG.md index c899f47..2ae0674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/Dockerfile b/Dockerfile index dd8bcc8..f3e07a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 " \ -org.opencontainers.image.authors="Maricopa County Library District developers " \ -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 " \ + org.opencontainers.image.authors="Maricopa County Library District developers " \ + 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"] diff --git a/README.md b/README.md index b6823ca..b2b328a 100644 --- a/README.md +++ b/README.md @@ -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): diff --git a/build.bash b/build.bash index b7cb18e..e88cc26 100755 --- a/build.bash +++ b/build.bash @@ -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: @@ -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 } @@ -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} @@ -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} @@ -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 @@ -311,7 +312,6 @@ 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 @@ -319,7 +319,6 @@ if [[ $BLD_PUSH = true ]]; then --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 diff --git a/buildscript.sln b/buildscript.sln index be1c867..f88e91a 100644 --- a/buildscript.sln +++ b/buildscript.sln @@ -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 diff --git a/release-prep.bash b/release-prep.bash index ad95c3a..bc0a073 100755 --- a/release-prep.bash +++ b/release-prep.bash @@ -7,61 +7,61 @@ script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) usage() { cat <&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 "$@" @@ -69,6 +69,13 @@ 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 + diff --git a/release-publish.bash b/release-publish.bash index 99acede..d4085d2 100755 --- a/release-publish.bash +++ b/release-publish.bash @@ -9,11 +9,12 @@ usage() { cat <