Skip to content

ci: add windows exe build #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
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
58 changes: 55 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,66 @@
name: Continuous Integration

on:
pull_request:
branches:
- main

jobs:
build:
name: Build
build-docker:
name: Build Docker
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build service
run: docker build .

build-windows:
name: Build Windows executable
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Perl for Windows build
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: "5.40"

- name: Install Perl dependencies for Windows build
run: |
cpanm --notest PAR::Packer
cpanm --notest Compress::Zlib
cpanm --notest Encode
cpanm --notest File::Basename
cpanm --notest File::Copy
cpanm --notest Getopt::Std
cpanm --notest HTTP::Cookies
cpanm --notest URI
cpanm --notest URI::Escape
cpanm --notest LWP::UserAgent
cpanm --notest LWP::ConnCache
cpanm --notest POSIX
cpanm --notest Time::Local
cpanm --notest Time::Piece
cpanm --notest JSON
cpanm --notest Sub::Util

- name: Build Windows executable
run: pp -o zap2xml.exe zap2xml.pl

- name: Copy entrypoint.bat
run: |
mkdir dist
copy .zap2xml-example dist\.zap2xml-example
copy entrypoint.bat dist\entrypoint.bat
copy zap2xml.exe dist\zap2xml.exe
shell: cmd

- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: zap2xml-windows
path: dist/
retention-days: 1
43 changes: 41 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,60 @@ on:

jobs:
build-tag-release:
name: Build, tag, and release Docker image
name: Build, tag, and release Docker image and Windows executable
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup release please
uses: google-github-actions/release-please-action@v2
uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-type: simple
changelog-path: CHANGELOG.md
package-name: zap2xml

- name: Setup Perl for Windows build
if: ${{ steps.release.outputs.release_created }}
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: "5.40"

- name: Install Perl dependencies for Windows build
if: ${{ steps.release.outputs.release_created }}
run: |
cpanm --notest PAR::Packer
cpanm --notest Compress::Zlib
cpanm --notest Encode
cpanm --notest File::Basename
cpanm --notest File::Copy
cpanm --notest Getopt::Std
cpanm --notest HTTP::Cookies
cpanm --notest URI
cpanm --notest URI::Escape
cpanm --notest LWP::UserAgent
cpanm --notest LWP::ConnCache
cpanm --notest POSIX
cpanm --notest Time::Local
cpanm --notest Time::Piece
cpanm --notest JSON

- name: Build Windows executable
if: ${{ steps.release.outputs.release_created }}
run: pp -o zap2xml.exe zap2xml.pl

- name: Upload Windows executable to release
if: ${{ steps.release.outputs.release_created }}
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Content-Type: application/octet-stream" \
--data-binary @zap2xml.exe \
"${{ steps.release.outputs.upload_url }}?name=zap2xml.exe&label=Windows%20Executable"

- name: Login into GitHub Container Registry
if: ${{ steps.release.outputs.release_created }}
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
Expand Down
11 changes: 11 additions & 0 deletions entrypoint.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo off
:loop
set DATESTR=%DATE% %TIME%
echo Running zap2xml.exe at %DATESTR%
zap2xml.exe %OPT_ARGS%
echo Last run time: %DATESTR%
echo Will run again in %SLEEPTIME% seconds
REM Default sleep time if not set
if "%SLEEPTIME%"=="" set SLEEPTIME=43200
powershell -Command "Start-Sleep -Seconds %SLEEPTIME%"
goto loop