Skip to content

Feature: Add powershell 20240417.0.0 images #179

Feature: Add powershell 20240417.0.0 images

Feature: Add powershell 20240417.0.0 images #179

Workflow file for this run

name: build
on:
push:
branches:
- master
tags:
- '**'
pull_request:
branches:
- master
jobs:
alpine:
runs-on: ubuntu-latest
strategy:
matrix:
PS_VERSION: [7.1.4, 7.1.5, 7.2.0, 7.2.1, 7.2.2, 7.3, 7.4]
OS: [alpine]
OS_VARIANT: ['3.11', '3.12', '3.13', '3.14', '3.15', '3.16', '3.17']
TOOL_VARIANT: [git, git-sudo]
include:
# Base and build image full tag
- PS_VERSION: 7.1.4
OS: alpine
OS_VARIANT: '3.11'
ARCHIVE: 20211005
- PS_VERSION: 7.1.4
OS: alpine
OS_VARIANT: '3.12'
ARCHIVE: 20211005
- PS_VERSION: 7.1.4
OS: alpine
OS_VARIANT: '3.13'
ARCHIVE: 20211005
- PS_VERSION: 7.1.5
OS: alpine
OS_VARIANT: '3.11'
ARCHIVE: 20211021
- PS_VERSION: 7.1.5
OS: alpine
OS_VARIANT: '3.12'
ARCHIVE: 20211021
- PS_VERSION: 7.1.5
OS: alpine
OS_VARIANT: '3.13'
ARCHIVE: 20211021
- PS_VERSION: 7.2.0
OS: alpine
OS_VARIANT: '3.11'
ARCHIVE: 20211102
- PS_VERSION: 7.2.0
OS: alpine
OS_VARIANT: '3.12'
ARCHIVE: 20211116
- PS_VERSION: 7.2.0
OS: alpine
OS_VARIANT: '3.13'
ARCHIVE: 20211116
- PS_VERSION: 7.2.0
OS: alpine
OS_VARIANT: '3.14'
ARCHIVE: 20211116
- PS_VERSION: 7.2.1
OS: alpine
OS_VARIANT: '3.12'
ARCHIVE: 20211215
- PS_VERSION: 7.2.1
OS: alpine
OS_VARIANT: '3.13'
ARCHIVE: 20220223
- PS_VERSION: 7.2.1
OS: alpine
OS_VARIANT: '3.14'
ARCHIVE: 20220223
- PS_VERSION: 7.2.2
OS: alpine
OS_VARIANT: '3.13'
ARCHIVE: 20220318
- PS_VERSION: 7.2.2
OS: alpine
OS_VARIANT: '3.14'
ARCHIVE: 20220318
# Excluded configurations
exclude:
- PS_VERSION: 7.1.4
OS: alpine
OS_VARIANT: '3.14'
- PS_VERSION: 7.1.4
OS: alpine
OS_VARIANT: '3.15'
- PS_VERSION: 7.1.4
OS: alpine
OS_VARIANT: '3.16'
- PS_VERSION: 7.1.4
OS: alpine
OS_VARIANT: '3.17'
- PS_VERSION: 7.1.5
OS: alpine
OS_VARIANT: '3.14'
- PS_VERSION: 7.1.5
OS: alpine
OS_VARIANT: '3.15'
- PS_VERSION: 7.1.5
OS: alpine
OS_VARIANT: '3.16'
- PS_VERSION: 7.1.5
OS: alpine
OS_VARIANT: '3.17'
- PS_VERSION: 7.2.0
OS: alpine
OS_VARIANT: '3.15'
- PS_VERSION: 7.2.0
OS: alpine
OS_VARIANT: '3.16'
- PS_VERSION: 7.2.0
OS: alpine
OS_VARIANT: '3.17'
- PS_VERSION: 7.2.1
OS: alpine
OS_VARIANT: '3.11'
- PS_VERSION: 7.2.1
OS: alpine
OS_VARIANT: '3.15'
- PS_VERSION: 7.2.1
OS: alpine
OS_VARIANT: '3.16'
- PS_VERSION: 7.2.1
OS: alpine
OS_VARIANT: '3.17'
- PS_VERSION: 7.2.2
OS: alpine
OS_VARIANT: '3.11'
- PS_VERSION: 7.2.2
OS: alpine
OS_VARIANT: '3.12'
- PS_VERSION: 7.2.2
OS: alpine
OS_VARIANT: '3.15'
- PS_VERSION: 7.2.2
OS: alpine
OS_VARIANT: '3.16'
- PS_VERSION: 7.2.2
OS: alpine
OS_VARIANT: '3.17'
- PS_VERSION: 7.3
OS: alpine
OS_VARIANT: '3.11'
- PS_VERSION: 7.3
OS: alpine
OS_VARIANT: '3.12'
- PS_VERSION: 7.4
OS: alpine
OS_VARIANT: '3.11'
- PS_VERSION: 7.4
OS: alpine
OS_VARIANT: '3.12'
- PS_VERSION: 7.4
OS: alpine
OS_VARIANT: '3.13'
- PS_VERSION: 7.4
OS: alpine
OS_VARIANT: '3.14'
- PS_VERSION: 7.4
OS: alpine
OS_VARIANT: '3.15'
env:
PS_VERSION: ${{ matrix.PS_VERSION }}
OS: ${{ matrix.OS }}
OS_VARIANT: ${{ matrix.OS_VARIANT }}
TOOL_VARIANT: ${{ matrix.TOOL_VARIANT }}
TAG_LATEST: ${{ matrix.TAG_LATEST }}
BASE_REGISTRY_NAMESPACE: mcr.microsoft.com
BASE_IMAGE_NAME: powershell
BASE_TAG_FULL: ${{ matrix.PS_VERSION }}-${{ matrix.OS }}-${{ matrix.OS_VARIANT }}-${{ matrix.ARCHIVE }}
BUILD_REGISTRY_NAMESPACE: ${{ vars.DOCKERHUB_REGISTRY_USER }}
BUILD_IMAGE_NAME: powershell
BUILD_TAG_FULL: ${{ matrix.PS_VERSION }}-${{ matrix.OS }}-${{ matrix.OS_VARIANT }}-${{ matrix.ARCHIVE }}-${{ matrix.TOOL_VARIANT }}
BUILD_CONTEXT: variants/${{ matrix.OS }}/${{ matrix.TOOL_VARIANT }}
steps:
- uses: actions/checkout@v3
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
lscpu
free
df -h
pwd
docker info
docker version
- name: Login to docker registry
run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin
env:
DOCKERHUB_REGISTRY_USER: ${{ vars.DOCKERHUB_REGISTRY_USER }}
DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
- name: Build image
run: |
set -e
echo "PS_VERSION: $PS_VERSION"
echo "OS: $OS"
echo "OS_VARIANT: $OS_VARIANT"
echo "TOOL_VARIANT: $TOOL_VARIANT"
echo "TAG_LATEST: $TAG_LATEST"
echo "BASE_REGISTRY_NAMESPACE: $BASE_REGISTRY_NAMESPACE"
echo "BASE_IMAGE_NAME: $BASE_IMAGE_NAME"
echo "BASE_TAG_FULL: $BASE_TAG_FULL"
echo "BUILD_REGISTRY_NAMESPACE: $BUILD_REGISTRY_NAMESPACE"
echo "BUILD_IMAGE_NAME: $BUILD_IMAGE_NAME"
echo "BUILD_TAG_FULL: $BUILD_TAG_FULL"
echo "BUILD_CONTEXT: $BUILD_CONTEXT"
echo "BASE_IMAGE: ${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL}"
echo "BUILD_IMAGE: ${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}"
export BASE_TAG_FULL_REGEX=$( echo "$BASE_TAG_FULL" | rev | sed -rn 's/^-*(.+)/\1/p' | rev )
echo "BASE_TAG_FULL_REGEX: $BASE_TAG_FULL_REGEX"
time docker pull "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" || true
export PS_VERSION_TRUNC=$( echo "$PS_VERSION" | sed -rn 's/([0-9]\.[0-9]).*/\1/p' )
# Get full PS version for PS 7.3 and later
if [ 1 -eq "$( echo "$PS_VERSION_TRUNC >= 7.3" | bc )" ]; then
export PS_VERSION_FULL=$( docker run -t --rm --entrypoint /bin/sh "${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" -c "pwsh --version | sed -rn 's/PowerShell ([0-9]\.[0-9]\.[0-9])/\1/p'" | tr -d '\r' )
echo "PS_VERSION_FULL: $PS_VERSION_FULL"
fi
time docker build \
--cache-from "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" \
-t "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" \
--build-arg BASE_IMAGE="${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" \
"$BUILD_CONTEXT"
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${PS_VERSION}-${OS}-${OS_VARIANT}-${TOOL_VARIANT}"
if [ "${TAG_LATEST}" = 'true' ]; then
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:latest"
fi
if [ 1 -eq "$( echo "$PS_VERSION_TRUNC >= 7.3" | bc )" ]; then
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${PS_VERSION_FULL}-${OS}-${OS_VARIANT}-${TOOL_VARIANT}"
fi
docker images
docker inspect "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}"
# Set job variables for later steps
echo "BASE_TAG_FULL_REGEX=$BASE_TAG_FULL_REGEX" >> $GITHUB_ENV
- name: Test image
run: docker run -t --rm --entrypoint pwsh "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" -c '$PSVersionTable'
- name: Push image
if: startsWith(github.ref, 'refs/tags/')
run: docker push -a "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}"
- name: Clean-up
if: always()
run: docker logout
ubuntu:
runs-on: ubuntu-latest
strategy:
matrix:
PS_VERSION: [7.1.4, 7.1.5, 7.2.0, 7.2.1, 7.2.2, 7.3, 7.4]
OS: [ubuntu]
OS_VARIANT: [18.04, 20.04, 22.04]
TOOL_VARIANT: [git, git-sudo]
include:
# Base and build image full tag
- PS_VERSION: 7.1.4
OS: ubuntu
OS_VARIANT: 18.04
ARCHIVE: 20211005
- PS_VERSION: 7.1.4
OS: ubuntu
OS_VARIANT: 20.04
ARCHIVE: 20211005
- PS_VERSION: 7.1.5
OS: ubuntu
OS_VARIANT: 18.04
ARCHIVE: 20211021
- PS_VERSION: 7.1.5
OS: ubuntu
OS_VARIANT: 20.04
ARCHIVE: 20211021
- PS_VERSION: 7.2.0
OS: ubuntu
OS_VARIANT: 18.04
ARCHIVE: 20211116
- PS_VERSION: 7.2.0
OS: ubuntu
OS_VARIANT: 20.04
ARCHIVE: 20211116
- PS_VERSION: 7.2.1
OS: ubuntu
OS_VARIANT: 18.04
ARCHIVE: 20220223
- PS_VERSION: 7.2.1
OS: ubuntu
OS_VARIANT: 20.04
ARCHIVE: 20220223
- PS_VERSION: 7.2.2
OS: ubuntu
OS_VARIANT: 18.04
ARCHIVE: 20220318
- PS_VERSION: 7.2.2
OS: ubuntu
OS_VARIANT: 20.04
ARCHIVE: 20220318
# Build image default tagging
- PS_VERSION: 7.4
OS: ubuntu
OS_VARIANT: 22.04
TOOL_VARIANT: git
TAG_LATEST: true
# Excluded configurations
exclude:
- PS_VERSION: 7.1.4
OS: ubuntu
OS_VARIANT: '22.04'
- PS_VERSION: 7.1.5
OS: ubuntu
OS_VARIANT: '22.04'
- PS_VERSION: 7.2.0
OS: ubuntu
OS_VARIANT: '22.04'
- PS_VERSION: 7.2.1
OS: ubuntu
OS_VARIANT: '22.04'
- PS_VERSION: 7.2.2
OS: ubuntu
OS_VARIANT: '22.04'
- PS_VERSION: 7.3
OS: ubuntu
OS_VARIANT: '18.04'
- PS_VERSION: 7.4
OS: ubuntu
OS_VARIANT: '18.04'
env:
PS_VERSION: ${{ matrix.PS_VERSION }}
OS: ${{ matrix.OS }}
OS_VARIANT: ${{ matrix.OS_VARIANT }}
TOOL_VARIANT: ${{ matrix.TOOL_VARIANT }}
TAG_LATEST: ${{ matrix.TAG_LATEST }}
BASE_REGISTRY_NAMESPACE: mcr.microsoft.com
BASE_IMAGE_NAME: powershell
BASE_TAG_FULL: ${{ matrix.PS_VERSION }}-${{ matrix.OS }}-${{ matrix.OS_VARIANT }}-${{ matrix.ARCHIVE }}
BUILD_REGISTRY_NAMESPACE: ${{ vars.DOCKERHUB_REGISTRY_USER }}
BUILD_IMAGE_NAME: powershell
BUILD_TAG_FULL: ${{ matrix.PS_VERSION }}-${{ matrix.OS }}-${{ matrix.OS_VARIANT }}-${{ matrix.ARCHIVE }}-${{ matrix.TOOL_VARIANT }}
BUILD_CONTEXT: variants/${{ matrix.OS }}/${{ matrix.TOOL_VARIANT }}
steps:
- uses: actions/checkout@v3
- name: Display system info (linux)
run: |
set -e
hostname
whoami
cat /etc/*release
lscpu
free
df -h
pwd
docker info
docker version
- name: Login to docker registry
run: echo "${DOCKERHUB_REGISTRY_PASSWORD}" | docker login -u "${DOCKERHUB_REGISTRY_USER}" --password-stdin
env:
DOCKERHUB_REGISTRY_USER: ${{ vars.DOCKERHUB_REGISTRY_USER }}
DOCKERHUB_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
- name: Build image
run: |
set -e
echo "PS_VERSION: $PS_VERSION"
echo "OS: $OS"
echo "OS_VARIANT: $OS_VARIANT"
echo "TOOL_VARIANT: $TOOL_VARIANT"
echo "TAG_LATEST: $TAG_LATEST"
echo "BASE_REGISTRY_NAMESPACE: $BASE_REGISTRY_NAMESPACE"
echo "BASE_IMAGE_NAME: $BASE_IMAGE_NAME"
echo "BASE_TAG_FULL: $BASE_TAG_FULL"
echo "BUILD_REGISTRY_NAMESPACE: $BUILD_REGISTRY_NAMESPACE"
echo "BUILD_IMAGE_NAME: $BUILD_IMAGE_NAME"
echo "BUILD_TAG_FULL: $BUILD_TAG_FULL"
echo "BUILD_CONTEXT: $BUILD_CONTEXT"
echo "BASE_IMAGE: ${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL}"
echo "BUILD_IMAGE: ${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_TAG_FULL}"
export BASE_TAG_FULL_REGEX=$( echo "$BASE_TAG_FULL" | rev | sed -rn 's/^-*(.+)/\1/p' | rev )
echo "BASE_TAG_FULL_REGEX: $BASE_TAG_FULL_REGEX"
time docker pull "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" || true
export PS_VERSION_TRUNC=$( echo "$PS_VERSION" | sed -rn 's/([0-9]\.[0-9]).*/\1/p' )
# Get full PS version for PS 7.3 and later
if [ 1 -eq "$( echo "$PS_VERSION_TRUNC >= 7.3" | bc )" ]; then
export PS_VERSION_FULL=$( docker run -t --rm --entrypoint /bin/sh "${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" -c "pwsh --version | sed -rn 's/PowerShell ([0-9]\.[0-9]\.[0-9])/\1/p'" | tr -d '\r' )
echo "PS_VERSION_FULL: $PS_VERSION_FULL"
fi
time docker build \
--cache-from "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" \
-t "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" \
--build-arg BASE_IMAGE="${BASE_REGISTRY_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" \
"$BUILD_CONTEXT"
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${PS_VERSION}-${OS}-${OS_VARIANT}-${TOOL_VARIANT}"
if [ "${TAG_LATEST}" = 'true' ]; then
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:latest"
fi
if [ 1 -eq "$( echo "$PS_VERSION_TRUNC >= 7.3" | bc )" ]; then
docker tag "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${PS_VERSION_FULL}-${OS}-${OS_VARIANT}-${TOOL_VARIANT}"
fi
docker images
docker inspect "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}"
# Set job variables for later steps
echo "BASE_TAG_FULL_REGEX=$BASE_TAG_FULL_REGEX" >> $GITHUB_ENV
- name: Test image
run: docker run -t --rm --entrypoint pwsh "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}:${BASE_TAG_FULL_REGEX}" -c '$PSVersionTable'
- name: Push image
if: startsWith(github.ref, 'refs/tags/')
run: docker push -a "${BUILD_REGISTRY_NAMESPACE}/${BUILD_IMAGE_NAME}"
- name: Clean-up
if: always()
run: docker logout
update-draft-release:
needs: [alpine, ubuntu]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-draft-release:
needs: [alpine, ubuntu]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
publish: true
name: ${{ github.ref_name }} # E.g. 'master' or 'v1.2.3'
tag: ${{ github.ref_name }} # E.g. 'master' or 'v1.2.3'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
dockerhub-description:
needs: [alpine, ubuntu]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: peter-evans/dockerhub-description@v3
with:
username: ${{ vars.DOCKERHUB_REGISTRY_USER }}
password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }}
repository: ${{ vars.DOCKERHUB_REGISTRY_USER }}/powershell
short-description: ${{ github.event.repository.description }}
readme-filepath: README.md