Skip to content

Build Nginx (MSYS2) #80

Build Nginx (MSYS2)

Build Nginx (MSYS2) #80

Workflow file for this run

name: Build Nginx (MSYS2)
on:
workflow_dispatch:
inputs:
TAG:
description: 'Enter nginx git tag/branch (e.g., 1.28.0, 1.28.1):'
required: false
default: ''
type: string
jobs:
build:
runs-on: windows-2022
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
update: true
msystem: MINGW64
install: >
base-devel
mingw-w64-x86_64-toolchain
git
wget
patch
p7zip
pkgconf
openssl-devel
mingw-w64-x86_64-libiconv
mingw-w64-x86_64-libjpeg
mingw-w64-x86_64-xpm-nox
mingw-w64-x86_64-zlib
mingw-w64-x86_64-libheif
mingw-w64-x86_64-libavif
mingw-w64-x86_64-aom
mingw-w64-x86_64-dav1d
mingw-w64-x86_64-rav1e
mingw-w64-x86_64-libyuv
mingw-w64-x86_64-harfbuzz
mingw-w64-x86_64-freetype
mingw-w64-x86_64-fontconfig
mingw-w64-x86_64-brotli
mingw-w64-x86_64-libpng
mingw-w64-x86_64-libxslt
mingw-w64-x86_64-openjpeg2
mingw-w64-x86_64-openh264
mingw-w64-x86_64-x265
mingw-w64-x86_64-kvazaar
mingw-w64-x86_64-libwebp
mingw-w64-x86_64-libtiff
mingw-w64-x86_64-libimagequant
mingw-w64-x86_64-jbigkit
mingw-w64-x86_64-libdeflate
mingw-w64-x86_64-lerc
mingw-w64-x86_64-xz
mingw-w64-x86_64-zstd
mingw-w64-x86_64-expat
mingw-w64-x86_64-glib2
mingw-w64-x86_64-libgd
mingw-w64-x86_64-pcre2
mingw-w64-x86_64-geoip
mingw-w64-x86_64-libmaxminddb
- name: Prepare Git identity (anonymous)
run: |
NAME="${{ github.actor }}"
EMAIL="${{ github.actor }}@users.noreply.github.com"
echo "BUILD_USER_NAME=$NAME" >> $GITHUB_ENV
echo "BUILD_USER_EMAIL=$EMAIL" >> $GITHUB_ENV
- name: Normalize TAG input
run: |
RAW="release-${{ github.event.inputs.TAG }}"
if [ -z "$RAW" ] || [ "$RAW" = "latest" ]; then
echo "TAG=" >> $GITHUB_ENV
else
echo "TAG=$RAW" >> $GITHUB_ENV
fi
- name: Show toolchain versions
run: |
gcc --version
g++ --version
make --version
perl --version
- name: Build nginx (Release + Debug)
env:
TAG: ${{ env.TAG }}
BUILD_USER_NAME: ${{ env.BUILD_USER_NAME }}
BUILD_USER_EMAIL: ${{ env.BUILD_USER_EMAIL }}
run: |
chmod +x ./build.sh
./build.sh
- name: Resolve package name
id: pkgname
run: |
# Try to extract version from input TAG
RAW="${{ env.TAG }}"
VER=""
if [ -n "$RAW" ]; then
# Supported formats: 1.28, 1.28.0, v1.28.0, release-1.28.0
if echo "$RAW" | grep -Eiq '^[a-z-]*v?[0-9]+\.[0-9]+(\.[0-9]+)?$'; then
VER="$(echo "$RAW" | sed -E 's/^[^0-9]*v?([0-9]+\.[0-9]+(\.[0-9]+)?)$/\1/i')"
fi
fi
# If TAG didn’t give us a version — read build script output
if [ -z "$VER" ] && [ -f "Release/.env" ]; then
set -a; . Release/.env; set +a
VER="${NGINX_VERSION:-}"
fi
# Final package name
if [ -n "$VER" ]; then
PKG_NAME="nginx-${VER}.zip"
else
PKG_NAME="nginx-bin.zip"
fi
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_ENV
- name: Package nginx
run: |
chmod +x ./package.sh
./package.sh
- name: Generate release tag
id: gen_tag
shell: pwsh
run: |
echo "tag=${{ env.TAG }}" >> $env:GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.gen_tag.outputs.tag }}
body: "https://nginx.org/en/CHANGES"
files: Release/${{ env.PKG_NAME }}
- name: Cleanup Release dir
shell: pwsh
run: Remove-Item Release -Recurse -Force