Skip to content
Merged
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
65 changes: 65 additions & 0 deletions .github/workflows/release_debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,68 @@ name: Release Debian

on:
workflow_dispatch:
release:
types: published

env:
PACKAGE: ${{ github.event.repository.name }}
OBS_USER: thomaslepoix
OBS_PROJECT: home:${OBS_USER}:open-rflab

jobs:
run:

runs-on: ubuntu-latest

steps:
- name: Chekout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 'Dependencies: Nix'
uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v4

- name: Extract informations
id: extract
shell: bash
run: |
echo "upload_url=$(curl -sL ${{ github.api_url }}/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }}} | jq -r '.upload_url')" >> $GITHUB_OUTPUT
echo "version=$(git describe --tags --abbrev=7 | sed 's/-/+/g')" >> $GITHUB_OUTPUT

- name: Update CHANGELOG
if: ${{ github.event_name != 'release' }}
run: |
OLD_VERSION="$(head -1 CHANGELOG | sed -E 's/^\S+ \((\S+)\)$/\1/')"
tool/changelog_add_upstream_entry.sh CHANGELOG
[ "${OLD_VERSION}" != "${{ steps.extract.outputs.version }}" ] && \
echo "::warning title=Version updated::Version: ${OLD_VERSION} -> ${{ steps.extract.outputs.version }}%0AGit ref: ${{ github.ref_name }}"

- name: Package
run: nix build -L --no-update-lock-file --show-trace .#${{ env.PACKAGE }}DebSource

- name: Deploy source package as Github workflow artifact
uses: actions/upload-artifact@v4
with:
retention-days: 90
name: ${{ env.PACKAGE }}_${{ steps.extract.outputs.version }}.deb-src
path: |
result/${{ env.PACKAGE }}_${{ steps.extract.outputs.version }}.dsc
result/${{ env.PACKAGE }}_${{ steps.extract.outputs.version }}.tar.xz

- name: Deploy source package on OBS
run: |
FILES={
FILES+=result/${{ env.PACKAGE }}_${{ steps.extract.outputs.version }}.dsc,
FILES+=result/${{ env.PACKAGE }}_${{ steps.extract.outputs.version }}.tar.xz
FILES+=}
curl \
--fail-with-body \
--user ${{ env.OBS_USER }}:${{ secrets.OBS_PASSWORD }} \
https://api.opensuse.org/source/${{ env.OBS_PROJECT }}/${{ env.PACKAGE }}/ \
-T "${FILES}"
26 changes: 14 additions & 12 deletions .github/workflows/release_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,23 @@ jobs:
- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v4

- name: Build
run: nix build -L --no-update-lock-file --show-trace --impure .#${{ env.PACKAGE }}Mingw64Zip

- name: Extract informations
id: extract
shell: bash
run: |
echo "upload_url=$(curl -sL ${{ github.api_url }}/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }}} | jq -r '.upload_url')" >> $GITHUB_OUTPUT
echo "version=$(nix derivation show --impure .#${{ env.PACKAGE }}Mingw64 | jq -r 'to_entries | .[0].value.env.version')" >> $GITHUB_OUTPUT
echo "git_describe=$(git describe --tags --dirty --abbrev=7 | sed 's/-/+/')" >> $GITHUB_OUTPUT
echo "version=$(git describe --tags --abbrev=7 | sed 's/-/+/g')" >> $GITHUB_OUTPUT

- name: Update CHANGELOG
if: ${{ github.event_name != 'release' }}
run: |
OLD_VERSION="$(head -1 CHANGELOG | sed -E 's/^\S+ \((\S+)\)$/\1/')"
tool/changelog_add_upstream_entry.sh CHANGELOG
[ "${OLD_VERSION}" != "${{ steps.extract.outputs.version }}" ] && \
echo "::warning title=Version updated::Version: ${OLD_VERSION} -> ${{ steps.extract.outputs.version }}%0AGit ref: ${{ github.ref_name }}"

- name: Build
run: nix build -L --no-update-lock-file --show-trace --impure .#${{ env.PACKAGE }}Mingw64Zip

- name: Deploy .zip as Github release asset
if: ${{ github.event_name == 'release' }}
Expand All @@ -57,11 +64,6 @@ jobs:
with:
# TODO Currently no way not to double zip.
# https://github.com/actions/upload-artifact/issues/39
name: ${{ env.PACKAGE }}-x86_64-w64-mingw32-${{ steps.extract.outputs.git_describe }}.zip
path: result/${{ env.PACKAGE }}-x86_64-w64-mingw32-${{ steps.extract.outputs.version }}.zip
retention-days: 90

- name: Warn for manual trigger
if: ${{ github.event_name != 'release' }}
run: |
echo "::warning title=Manual trigger::Package is uploaded as workflow artifact instead of release asset.%0AGit ref: ${{ github.ref_name }}%0AGit describe: ${{ steps.extract.outputs.git_describe }}"
name: ${{ env.PACKAGE }}-x86_64-w64-mingw32-${{ steps.extract.outputs.version }}.zip
path: result/${{ env.PACKAGE }}-x86_64-w64-mingw32-${{ steps.extract.outputs.version }}.zip
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
openemsh (0.0.0)

* Project creation

-- Thomas Lepoix <thomas.lepoix@protonmail.ch> 13 Feb 2021
21 changes: 20 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
cmake_minimum_required( VERSION 3.16 )

# PROJECT_VERSION_LONG : <V>.<V>.<V>+<N>+g<H> (Debian native compatible `git describe --tags`)
# PROJECT_VERSION : <V>.<V>.<V>.<N>
file( STRINGS "${CMAKE_SOURCE_DIR}/CHANGELOG" PROJECT_VERSION
LIMIT_COUNT 1
)
string( REGEX REPLACE
"^[^ ]+ \\((.*)\\)$" "\\1"
PROJECT_VERSION_LONG "${PROJECT_VERSION}"
)
string( REGEX REPLACE
"[\\+~-]" "."
PROJECT_VERSION "${PROJECT_VERSION}"
)
string( REGEX REPLACE
"^[^ ]+ \\(([0-9]+(\\.[0-9]+)?(\\.[0-9]+)?(\\.[0-9]+)?).*\\)$" "\\1"
PROJECT_VERSION "${PROJECT_VERSION}"
)

project( openemsh
LANGUAGES CXX
VERSION 0.0.0
VERSION "${PROJECT_VERSION}"
DESCRIPTION "openEMS mesher"
HOMEPAGE_URL "https://github.com/Open-RFlab/openemsh"
)
Expand Down Expand Up @@ -113,6 +131,7 @@ set( CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
add_subdirectory( "${CMAKE_SOURCE_DIR}/src" )
add_subdirectory( "${CMAKE_SOURCE_DIR}/test" )
add_subdirectory( "${CMAKE_SOURCE_DIR}/icon" )
add_subdirectory( "${CMAKE_SOURCE_DIR}/pack" )
add_subdirectory( "${CMAKE_SOURCE_DIR}/doc" )

if( CMakeUtils_FOUND )
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![SonarCloud quality gate](https://sonarcloud.io/api/project_badges/measure?project=Open-RFlab_openemsh&metric=alert_status)](https://sonarcloud.io/dashboard?id=Open-RFlab_openemsh)
[![SonarCloud coverage](https://sonarcloud.io/api/project_badges/measure?project=Open-RFlab_openemsh&metric=coverage)](https://sonarcloud.io/dashboard?id=Open-RFlab_openemsh)

[![Package Debian](https://img.shields.io/github/actions/workflow/status/Open-RFlab/openemsh/release_debian.yml?label=package&logo=debian)](https://software.opensuse.org/download.html?project=home:thomaslepoix:open-rflab&package=openemsh)
[![Package Windows](https://img.shields.io/github/actions/workflow/status/Open-RFlab/openemsh/release_windows.yml?label=package&logo=mingww64)](https://github.com/Open-RFlab/openemsh/releases)

# OpenEMSH : OpenEMS Mesher [WIP]
Expand Down
5 changes: 5 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release process

- Update `CHANGELOG`.
- Use `tool/changelog_2_md.sh` to help produce the release text.
- Publish a Github release (Windows executable will be automatically produced and uploaded on the release page, Debian source package will be forwarded to OBS).
8 changes: 7 additions & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@

stdenv.mkDerivation {
pname = "openemsh";
version = "0.0.0";
version =
let
firstLine = builtins.elemAt (lib.strings.split "\n" (builtins.readFile ./CHANGELOG)) 0;
in builtins.elemAt (builtins.match "^[^ ]+ \\((.*)\\)$" firstLine) 0;

src = lib.nix-filter {
root = ./.;
include = [
"cmake"
"src"
"debian"
"doc"
"icon"
"pack"
"test"
"CMakeLists.txt"
"CMakePresets.json"
"CHANGELOG"
];
};

Expand Down
14 changes: 14 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
add_custom_target( doc )

file( ARCHIVE_CREATE
OUTPUT "${CMAKE_BINARY_DIR}/doc/changelog.gz"
PATHS "${CMAKE_SOURCE_DIR}/CHANGELOG"
FORMAT raw
COMPRESSION GZip
COMPRESSION_LEVEL 9
)

install(
FILES "${CMAKE_BINARY_DIR}/doc/changelog.gz"
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
CONFIGURATIONS Release
)

if( D2 )

set( D2_INDIVIDUAL_STEPS_FILES
Expand Down
34 changes: 32 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
mkdir -p $out/bin
printf '${script}' > $out/bin/${package.pname}
chmod +x $out/bin/${package.pname}
# mkdir -p $out/share
# ${pkgs.xorg.lndir}/bin/lndir -silent ${package}/share $out/share
mkdir -p $out/share
${pkgs.xorg.lndir}/bin/lndir -silent ${package}/share $out/share
'';
};

Expand All @@ -87,6 +87,35 @@
'';
};

debianSource = package: { distributions ? [ "unstable" ], metadata ? [ "urgency=medium" ] }:
pkgs.stdenvNoCC.mkDerivation {
inherit (package) version meta src;
pname = "${package.pname}-deb-source";
doCheck = false;
nativeBuildInputs = [ pkgs.dpkg ];
unpackPhase = ''
cp -r ${package.src} ${package.name}
chmod -R u+w ${package.name}
'';
patchPhase = ''
mv ${package.name}/pack/debian ${package.name}/debian
# Add APT stuff and reformat timestamps
# https://manpages.debian.org/testing/dpkg-dev/deb-changelog.5.en.html
sed < ${package.name}/CHANGELOG -E \
-e 's/^(\S+ \(\S+\))$/\1 ${toString distributions}; ${lib.strings.concatStringsSep "," metadata}/g' \
-e 's/^( -- .+ <\S+@\S+> )([0-9]{1,2} [a-zA-Z]{3} [0-9]{4})$/echo "\1$(date -R --date "\2")"/e' \
> ${package.name}/debian/changelog
cat ${package.name}/debian/changelog
'';
buildPhase = ''
dpkg-source -b ${package.name}
'';
installPhase = ''
mkdir -p $out
mv ${package.pname}_${package.version}.* $out/
'';
};

in {
devShells = {
default = pkgs.mkShell {
Expand Down Expand Up @@ -126,6 +155,7 @@
openemshMingw64 = pkgs-mingw.openemshMingw64;
openemshMingw64Zip = zipWrapper pkgs-mingw.openemshMingw64;
openemshWine64 = wineWrapper (pkgs-mingw.openemshMingw64.override { withPortabilityTweaks = true; });
openemshDebSource = debianSource pkgs.openemsh {};
};
}) // {
overlays = {
Expand Down
16 changes: 16 additions & 0 deletions icon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,19 @@ if( CMakeUtils_Icon_FOUND )
COMMENT "Copying icon png and ico files back to ${CMAKE_CURRENT_SOURCE_DIR}/"
)
endif()

foreach( I IN ITEMS 256 128 64 48 32 22 16 )
install(
FILES "${CMAKE_SOURCE_DIR}/icon/openemsh.${I}.png"
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/${I}x${I}/apps"
RENAME "openemsh.png"
CONFIGURATIONS Release
)
endforeach()

install(
FILES "${CMAKE_SOURCE_DIR}/icon/openemsh.svg"
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps"
RENAME "openemsh.svg"
CONFIGURATIONS Release
)
6 changes: 6 additions & 0 deletions pack/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

install(
FILES "${CMAKE_SOURCE_DIR}/pack/openemsh.desktop"
DESTINATION "${CMAKE_INSTALL_DATADIR}/applications"
CONFIGURATIONS Release
)
1 change: 1 addition & 0 deletions pack/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Placeholder for a slightly reformated copy of CHANGELOG, see flake.nix
1 change: 1 addition & 0 deletions pack/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10
24 changes: 24 additions & 0 deletions pack/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Source: openemsh
Section: electronics
Priority: optional
Maintainer: Thomas Lepoix <thomas.lepoix@protonmail.ch>
Uploaders: Thomas Lepoix <thomas.lepoix@protonmail.ch>
Homepage: https://github.com/Open-RFlab/openemsh
Vcs-Git: https://github.com/Open-RFlab/openemsh
Vcs-Browser: https://github.com/Open-RFlab/openemsh
Build-Depends:
debhelper,
gcc (>= 13),
cmake,
qt6-base-dev,
libcli11-dev (>= 2.4),
libpugixml-dev
# texlive-xetex
# fonts-lato

Package: openemsh
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}
Suggests: openems, octave-openems, python3-openems
Enhances: openems, octave-openems, python3-openems
Description: OpenEMS mesher draft
1 change: 1 addition & 0 deletions pack/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GPL-3.0-or-later
11 changes: 11 additions & 0 deletions pack/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/make -f

export DEB_BUILD_OPTIONS = nocheck

%:
dh $@

override_dh_auto_configure:
dh_auto_configure -- \
-DCMAKE_BUILD_TYPE=Release \
-DCPM_DISABLE=ON
1 change: 1 addition & 0 deletions pack/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (native)
8 changes: 8 additions & 0 deletions pack/openemsh.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Name=OpenEMSH
TryExec=openemsh
Exec=bash -c "F="%f" && test -n "$F" && openemsh -G -i $F || openemsh"
Icon=openemsh
Type=Application
Comment=OpenEMS mesher draft
Categories=Education;Electronics;
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ target_sources( openemsh_bin

target_compile_definitions( openemsh_bin
PRIVATE
OEMSH_VERSION="${PROJECT_VERSION}"
OEMSH_VERSION="${PROJECT_VERSION_LONG}"
OEMSH_HOMEPAGE="${PROJECT_HOMEPAGE_URL}"
OEMSH_FUNDING="${OEMSH_FUNDING}"
OEMSH_BUGREPORT="${OEMSH_BUGREPORT}"
Expand Down
Loading