Skip to content

Commit

Permalink
Merge pull request #361 from mmerklinger/cd-pipeline
Browse files Browse the repository at this point in the history
CD pipeline to build for Linux and Windows
  • Loading branch information
daringer authored Apr 6, 2023
2 parents 6c710cb + 2e48717 commit 660a3a3
Show file tree
Hide file tree
Showing 18 changed files with 575 additions and 214 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/cd-linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Continuous delivery - Linux

on:
release:
types: [published, unpublished]

env:
FLIT_ROOT_INSTALL: 1

jobs:
version-check:
name: Check versioning
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check version tag format
run: |
TAG_VERSION="${{ github.event.release.tag_name }}"
if [[ $TAG_VERSION =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]]; then exit 0; else exit 1; fi
- name: Check if version tag and package version are equal
run: |
TAG_VERSION="${{ github.event.release.tag_name }}"
if [ ${TAG_VERSION:1} == $(cat pynitrokey/VERSION) ]; then exit 0; else exit 1; fi
build-onefile:
name: Build onefile
runs-on: ubuntu-latest
container: python:3.9-slim
needs: version-check
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install required packages
run: |
apt update
apt install -y binutils gcc libpcsclite-dev libusb-1.0-0 make swig
- name: Create virtual environment
run: |
python -m venv venv
. venv/bin/activate
pip install flit
flit install --symlink
- name: Build
run: |
. venv/bin/activate
pyinstaller \
ci-scripts/linux/pyinstaller/pynitrokey-onefile.spec
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: nitropy-onefile
path: dist/nitropy
publish-binary:
name: Publish binary
runs-on: ubuntu-latest
container: python:3.9-slim
needs: build-onefile
permissions:
contents: write
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: nitropy-onefile
- name: Rename binary
run: |
mv \
nitropy \
nitropy-${{ github.event.release.tag_name }}-x64-linux-binary
- name: Create archive
run: |
tar \
-czvf \
nitropy-${{ github.event.release.tag_name }}-x64-linux-binary.tar.gz \
nitropy-${{ github.event.release.tag_name }}-x64-linux-binary
- name: Publish release
uses: softprops/action-gh-release@v1
with:
files: nitropy-${{ github.event.release.tag_name }}-x64-linux-binary.tar.gz
178 changes: 178 additions & 0 deletions .github/workflows/cd-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: Continuous delivery - Windows

on:
release:
types: [published, unpublished]

env:
FLIT_ROOT_INSTALL: 1

jobs:
version-check:
name: Check versioning
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check version tag format
run: |
$VERSION_TAG="${{ github.event.release.tag_name }}"
if ($VERSION_TAG -match "^v[0-9]+.[0-9]+.[0-9]+$") {exit 0} else {exit 1}
- name: Check if version tag and package version are equal
run: |
$VERSION_TAG="${{ github.event.release.tag_name }}"
$VERSION_FILE=Get-Content .\pynitrokey\VERSION
if ($VERSION_TAG.Substring(1) -eq $VERSION_FILE) {exit 0} else {exit 1}
build-onedir:
name: Build onedir
runs-on: windows-latest
needs: version-check
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create virtual environment
run: |
python -m venv venv
.\venv\Scripts\Activate.ps1
.\venv\Scripts\pip install pip
.\venv\Scripts\pip install flit
.\venv\Scripts\flit install --symlink
- name: Create Windows version info file
run: |
.\venv\Scripts\Activate.ps1
create-version-file `
--outfile .\ci-scripts\windows\pyinstaller\file_version_info.txt `
--version "$(Get-Content .\pynitrokey\VERSION)" `
.\ci-scripts\windows\pyinstaller\file_version_info_metadata.yaml
- name: Build onedir
run: |
.\venv\Scripts\Activate.ps1
pyinstaller ci-scripts/windows/pyinstaller/pynitrokey-onedir.spec
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: pynitrokey-onedir
path: dist/nitropy
build-onefile:
name: Build onefile
runs-on: windows-latest
needs: version-check
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create virtual environment
run: |
python -m venv venv
.\venv\Scripts\Activate.ps1
.\venv\Scripts\pip install pip
.\venv\Scripts\pip install flit
.\venv\Scripts\flit install --symlink
- name: Create Windows version info file
run: |
.\venv\Scripts\Activate.ps1
create-version-file `
--outfile .\ci-scripts\windows\pyinstaller\file_version_info.txt `
--version "$(Get-Content .\pynitrokey\VERSION)" `
.\ci-scripts\windows\pyinstaller\file_version_info_metadata.yaml
- name: Build onefile
run: |
.\venv\Scripts\Activate.ps1
pyinstaller ci-scripts/windows/pyinstaller/pynitrokey-onefile.spec
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: pynitrokey-onefile
path: dist/nitropy.exe
build-msi-installer:
name: Build MSI installer
runs-on: windows-latest
needs: build-onedir
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: pynitrokey-onedir
path: dist/nitropy
- name: Create sources file
run: |
$Env:Path += ";" + "$Env:WIX" + "bin"
heat `
dir .\dist\nitropy\ `
-dr INSTALLFOLDER `
-ag `
-cg ApplicationFilesDynamic `
-ke `
-srd -sfrag -suid -sreg `
-nologo `
-pog:Binaries `
-pog:Documents `
-pog:Satellites `
-pog:Sources `
-pog:Content `
-o Sources.wxs
- name: Build object files
run: |
$Env:Path += ";" + "$Env:WIX" + "bin"
candle .\ci-scripts\windows\wix\Product.wxs -o Product.wixobj
candle .\Sources.wxs -o .\Sources.wixobj
- name: Build installer package
run: |
$Env:Path += ";" + "$Env:WIX" + "bin"
light `
-b .\dist\nitropy\ `
-sice:ICE80 `
.\Product.wixobj `
.\Sources.wixobj `
-o nitropy.msi
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: nitropy-installer
path: nitropy.msi
publish-binary:
name: Publish binary
runs-on: windows-latest
needs: build-onefile
permissions:
contents: write
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: pynitrokey-onefile
- name: Rename binary
run: |
mv `
nitropy.exe `
nitropy-${{ github.event.release.tag_name }}-x64-windows-binary.exe
- name: Create archive
run: |
7z a -tzip -mx9 `
nitropy-${{ github.event.release.tag_name }}-x64-windows-binary.zip `
nitropy-${{ github.event.release.tag_name }}-x64-windows-binary.exe
- name: Publish release
uses: softprops/action-gh-release@v1
with:
files: nitropy-${{ github.event.release.tag_name }}-x64-windows-binary.zip
publish-msi-installer:
name: Publish MSI installer
runs-on: windows-latest
needs: build-msi-installer
permissions:
contents: write
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: nitropy-installer
- name: Rename installer
run: |
mv `
nitropy.msi `
nitropy-${{ github.event.release.tag_name }}-x64-windows-installer.msi
- name: Publish release
uses: softprops/action-gh-release@v1
with:
files: nitropy-${{ github.event.release.tag_name }}-x64-windows-installer.msi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# before adding to this file

dist/
build/
venv/
venv-ci/
firmware-*.json
Expand Down
19 changes: 0 additions & 19 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,6 @@ build-pypi:
paths:
- artifacts

build-msi:
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- if: '$CI_PIPELINE_SOURCE == "web"'
tags:
- lxc
stage: build
script:
- make wine-build
after_script:
- wget $icon_server/checkmark/$CI_COMMIT_REF_NAME/$CI_COMMIT_SHA/$CI_JOB_NAME/$CI_JOB_STATUS/${CI_JOB_URL#*/*/*/} || true
- mkdir -p artifacts
- cp wine-build/*.exe artifacts
- cp wine-build/*.msi artifacts
artifacts:
paths:
- artifacts

build-and-publish-pypi:
rules:
- if: '$CI_PIPELINE_SOURCE == "web"'
Expand Down
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@ nethsm-client: nethsm-api.yaml
-g=python -o=/out/python --package-name=pynitrokey.nethsm.client
cp -r "${OPENAPI_OUTPUT_DIR}/python/pynitrokey/nethsm/client" pynitrokey/nethsm

.PHONY: wine-build
wine-build: wine-build/pynitrokey-$(VERSION).msi wine-build/nitropy-$(VERSION).exe

wine-build/pynitrokey-$(VERSION).msi wine-build/nitropy-$(VERSION).exe:
bash build-wine.sh
#cp wine-build/out/pynitrokey-$(VERSION)-win32.msi wine-build
cp wine-build/out/nitropy-$(VERSION).exe wine-build


.PHONY: secrets-test-all secrets-test
TESTPARAM=-x -s -o log_cli=true
secrets-test-all: init
Expand Down
6 changes: 2 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

# Release Process
1. Bump version in pynitrokey/VERSION. Use 0.x.y format.
2. Make an annotated tag in format v0.x.y.nitrokey, with message describing major change.
3. Run CI release to release it
1. Bump version in pynitrokey/VERSION. Use `0.x.y` format.
2. Create a release in the Github UI with the tag in format `v0.x.y`. The CD pipeline will run automatically on a new release.
27 changes: 0 additions & 27 deletions build-wine.sh

This file was deleted.

Loading

0 comments on commit 660a3a3

Please sign in to comment.