chore: Update authentication handler to log client IP and hostname #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: write | |
attestations: write | |
packages: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [windows, linux, darwin] | |
goarch: [386, amd64, arm64] | |
exclude: | |
- goos: darwin | |
goarch: 386 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.22 | |
- name: Build | |
run: | | |
mkdir -p build/${{ matrix.goos }}-${{ matrix.goarch }} | |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o nginx-ad-auth-${{ matrix.goos }}-${{ matrix.goarch }} | |
- name: Attest release | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-path: 'nginx-ad-auth-${{ matrix.goos }}-${{ matrix.goarch }}' | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.goos }}-${{ matrix.goarch }} | |
path: nginx-ad-auth-${{ matrix.goos }}-${{ matrix.goarch }} | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- name: Get current date | |
id: getdate | |
run: | | |
echo "$(date +'%Y.%m.%d-%H%M')" > version | |
echo "::set-output name=getdate::$(cat version)" | |
cat version | |
- name: Upload version as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: version | |
path: version | |
- uses: actions/checkout@v4 | |
- name: Create Release with gh | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release create v${{ steps.getdate.outputs.getdate }} -t "Release ${{ steps.getdate.outputs.getdate }}" -n "Release ${{ steps.getdate.outputs.getdate }}" | |
- uses: actions/download-artifact@v4 | |
- name: Upload Release Assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mkdir -p release | |
mv darwin-amd64/* release/nginx-ad-auth-darwin-amd64 | |
mv darwin-arm64/* release/nginx-ad-auth-darwin-arm64 | |
mv linux-amd64/* release/nginx-ad-auth-linux-amd64 | |
mv linux-arm64/* release/nginx-ad-auth-linux-arm64 | |
mv windows-386/* release/nginx-ad-auth-windows-386.exe | |
mv windows-amd64/* release/nginx-ad-auth-windows-amd64.exe | |
gh release upload v${{ steps.getdate.outputs.getdate }} release/* | |
deb-package: | |
name: debian package - ${{ matrix.job.name }} | |
needs: create-release | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
job: | |
- { name: "amd64", debian_platform: "amd64", crossbuild_package: "" } | |
- { name: "arm64", debian_platform: "arm64", crossbuild_package: "crossbuild-essential-arm64" } | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Create packaging env | |
run: | | |
sudo apt update | |
DEBIAN_FRONTEND=noninteractive sudo apt install -y devscripts build-essential debhelper pkg-config ${{ matrix.job.crossbuild_package }} | |
mkdir -p debian-build/${{ matrix.job.name }}/bin | |
- name: Download binaries | |
uses: actions/download-artifact@v4 | |
- name: Build package for ${{ matrix.job.name }} arch | |
run: | | |
echo "Building package for ${{ matrix.job.name }} arch with version $VERSION" | |
cp -v linux-${{ matrix.job.name }}/* debian-build/${{ matrix.job.name }}/bin/nginx-ad-auth | |
chmod -v a+x debian-build/${{ matrix.job.name }}/bin/* | |
cp -vr debian systemd debian-build/${{ matrix.job.name }}/ | |
cat debian/control.tpl | sed 's/{{ ARCH }}/${{ matrix.job.debian_platform }}/' > debian-build/${{ matrix.job.name }}/debian/control | |
cd debian-build/${{ matrix.job.name }}/ | |
debuild -i -us -uc -b -a${{ matrix.job.debian_platform }} | |
- name: Upload Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ls -lR | |
export VERSION=$(cat version/version) | |
gh release upload v$VERSION debian-build/nginx-ad-auth_*_${{ matrix.job.debian_platform }}.deb | |