feat!: build with CMake and release with semantic-release (#118)

BREAKING CHANGE: Drops Windows XP support

* refactor: code review suggestion

* ci: move print help to build job

* refactor: code review suggestion

* build: fix

* docs: clarify where releases are
This commit is contained in:
David Sanders
2023-11-15 14:03:14 -08:00
committed by GitHub
parent 824746d522
commit b1f8a3babe
14 changed files with 200 additions and 264 deletions
-42
View File
@@ -1,42 +0,0 @@
image: Visual Studio 2017
configuration: Default
platform:
- x64
- Win32
before_build:
- cmd: |
git clone --depth 1 https://chromium.googlesource.com/external/gyp
gyp\gyp rcedit.gyp --depth .
build:
project: rcedit.sln
parallel: true
verbosity: minimal
after_build:
- cmd: if %PLATFORM%==Win32 (move Default\rcedit.exe Default\rcedit-x86.exe)
- cmd: if %PLATFORM%==x64 (move Default\rcedit.exe Default\rcedit-x64.exe)
branches:
only:
- master
artifacts:
- path: Default\*.exe
deploy:
- provider: GitHub
release: Rcedit $(APPVEYOR_REPO_TAG_NAME)
tag: $(APPVEYOR_REPO_TAG_NAME)
description: '(placeholder)'
auth_token:
secure: lVaYho+MDDKAQH4aImQub/L5ORlENgZ4utufxWAetovWnIsWiwFCkgFRIcIRMWz5
artifact: /.*\.exe/
draft: true
force_update: true
prerelease: false
on:
appveyor_repo_tag: true
+81
View File
@@ -0,0 +1,81 @@
name: Continuous Integration
on:
push:
branches:
- master
pull_request:
branches:
- master
permissions:
contents: read
jobs:
build:
name: Build
runs-on: windows-2022
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 1
- name: Build
run: |
cmake -E make_directory build/x64
cmake -E make_directory build/Win32
cd build/x64
cmake -A x64 ../../
cmake --build . --config RelWithDebInfo
cd ../../build/Win32
cmake -A Win32 ../../
cmake --build . --config RelWithDebInfo
- name: Copy to dist
run: |
cmake -E make_directory dist
cmake -E copy build/x64/RelWithDebInfo/rcedit.exe dist/rcedit-x64.exe
cmake -E copy build/Win32/RelWithDebInfo/rcedit.exe dist/rcedit-x86.exe
- name: Print help
run: |
dist/rcedit-x86.exe -h
dist/rcedit-x64.exe -h
- name: Upload artifacts
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: dist
path: dist/
release:
name: Release
runs-on: windows-2022
needs: build
if: github.ref == 'refs/heads/master'
permissions:
contents: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: dist
path: dist/
- run: npm install -g semantic-release@22.0.6 semantic-release-export-data@v1.0.1
- run: npx semantic-release@22.0.6 --dry-run
id: get-next-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Stamp version
if: steps.get-next-version.outputs.new-release-published == 'true'
run: |
set -eo pipefail
dist/rcedit-x64.exe dist/rcedit-x86.exe --set-product-version $VERSION --set-file-version $VERSION
dist/rcedit-x86.exe -h | grep -q Rcedit v$VERSION
dist/rcedit-x86.exe dist/rcedit-x64.exe --set-product-version $VERSION --set-file-version $VERSION
dist/rcedit-x64.exe -h | grep -q Rcedit v$VERSION
env:
VERSION: ${{ steps.get-next-version.outputs.new-release-version }}
- name: Run semantic release
run: npx semantic-release@22.0.6 --dry-run
if: steps.get-next-version.outputs.new-release-published == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+26
View File
@@ -0,0 +1,26 @@
name: "Check Semantic Commit"
on:
pull_request:
types:
- opened
- edited
- synchronize
permissions:
contents: read
jobs:
main:
permissions:
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- name: semantic-pull-request
uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: false
+1
View File
@@ -1,5 +1,6 @@
Default/
ipch/
build/
*.swp
*.sdf
+18
View File
@@ -0,0 +1,18 @@
{
"plugins": [
"semantic-release-export-data",
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/github",
{
"assets": [
{ "path": "dist/rcedit-x64.exe" },
{ "path": "dist/rcedit-x86.exe" }
],
"draftRelease": true
}
]
],
"branches": [ "master" ]
}
+12
View File
@@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 3.15)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
# /Ox, full optimization
# /Os, favour small code
add_compile_options(/Ox /Os)
project(rcedit)
add_executable(rcedit src/main.cc src/rescle.cc src/rcedit.rc)
target_link_libraries(rcedit version.lib)
+10 -12
View File
@@ -1,24 +1,22 @@
# rcedit [![Build status](https://ci.appveyor.com/api/projects/status/99eokln2emhidcej?svg=true)](https://ci.appveyor.com/project/zcbenz/rcedit/branch/master)
# rcedit
[![Continuous Integration](https://github.com/electron/rcedit/actions/workflows/ci.yml/badge.svg)](https://github.com/electron/rcedit/actions/workflows/ci.yml)
Command line tool to edit resources of exe file on Windows.
## Executables
Prebuilt binaries can be found in the artifacts of appveyor jobs.
Prebuilt binaries can be found in the [GitHub releases](https://github.com/electron/rcedit/releases).
## Building
To build you need CMake 3.15+ and Visual Studio 2015 or above.
1. Clone the repository
2. Open `rcedit.sln` with Visual Studio 2015 or above
3. Build
## Generate solution files
If you have modified the gyp files, you should regenerate the solution files:
1. Make sure you have gyp configured on your system. If not, clone gyp from
https://chromium.googlesource.com/external/gyp
2. Run `gyp rcedit.gyp --depth .`
2. Create a build directory: `cmake -E make_directory build`
3. Change to the build directory: `cd build`
4. Make the CMake project: `cmake ..`
5. Build: `cmake --build .`
## Docs
-40
View File
@@ -1,40 +0,0 @@
{
'targets': [
{
'target_name': 'rcedit',
'type': 'executable',
'sources': [
'src/main.cc',
'src/rescle.cc',
'src/rescle.h',
'src/rcedit.rc',
'src/version.h',
],
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': 1, # console executable
},
'VCCLCompilerTool': {
'Optimization': 3, # /Ox, full optimization
'FavorSizeOrSpeed': 1, # /Os, favour small code
'RuntimeLibrary': 0, # /MT, for statically linked runtime
},
},
'conditions': [
['MSVS_VERSION=="2015"', {
'msbuild_toolset': 'v140_xp',
}],
['MSVS_VERSION=="2017"', {
'msbuild_toolset': 'v141_xp',
}],
],
'configurations': {
'Default': {
},
'Default_x64': {
'msvs_configuration_platform': 'x64',
},
}
},
],
}
-19
View File
@@ -1,19 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2015
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rcedit", "rcedit.vcxproj", "{3609DBE4-DFE6-667B-C659-D6913E25C767}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Default|x64 = Default|x64
Default|Win32 = Default|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3609DBE4-DFE6-667B-C659-D6913E25C767}.Default|x64.ActiveCfg = Default|x64
{3609DBE4-DFE6-667B-C659-D6913E25C767}.Default|x64.Build.0 = Default|x64
{3609DBE4-DFE6-667B-C659-D6913E25C767}.Default|Win32.ActiveCfg = Default|Win32
{3609DBE4-DFE6-667B-C659-D6913E25C767}.Default|Win32.Build.0 = Default|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
-82
View File
@@ -1,82 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Default|Win32">
<Configuration>Default</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Default|x64">
<Configuration>Default</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3609DBE4-DFE6-667B-C659-D6913E25C767}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>rcedit</RootNamespace>
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
</PropertyGroup>
<PropertyGroup Label="Locals">
<PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
<ImportGroup Label="ExtensionSettings"/>
<ImportGroup Label="PropertySheets">
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
</ImportGroup>
<PropertyGroup Label="UserMacros"/>
<PropertyGroup>
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\.\bin\;$(MSBuildProjectDirectory)\.\bin\</ExecutablePath>
<IntDir>$(Configuration)\obj\$(ProjectName)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<TargetName>$(ProjectName)</TargetName>
<TargetPath>$(OutDir)\$(ProjectName)$(TargetExt)</TargetPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Default|Win32'">
<ClCompile>
<CompileAsWinRT>false</CompileAsWinRT>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<Optimization>Full</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalDependencies></AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName)$(TargetExt)</OutputFile>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Default|x64'">
<ClCompile>
<CompileAsWinRT>false</CompileAsWinRT>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<Optimization>Full</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<AdditionalDependencies></AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName)$(TargetExt)</OutputFile>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="rcedit.gyp"/>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\rescle.h"/>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main.cc"/>
<ClCompile Include="src\rescle.cc"/>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="src\rcedit.rc"/>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
<ImportGroup Label="ExtensionTargets"/>
</Project>
-32
View File
@@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
<Filter Include="src">
<UniqueIdentifier>{8CDEE807-BC53-E450-C8B8-4DEBB66742D4}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\main.cc">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\rescle.cc">
<Filter>src</Filter>
</ClCompile>
<ClInclude Include="src\rescle.h">
<Filter>src</Filter>
</ClInclude>
<ResourceCompile Include="src\rcedit.rc">
<Filter>src</Filter>
</ResourceCompile>
<None Include="rcedit.gyp"/>
</ItemGroup>
</Project>
+48 -5
View File
@@ -3,15 +3,47 @@
// LICENSE file.
#include <string.h>
#include <vector>
#include <windows.h>
#include <winver.h>
#include "rescle.h"
#include "version.h"
namespace {
void print_help() {
std::vector<uint8_t> get_file_version_info() {
DWORD zero = 0;
std::vector<wchar_t> filename(MAX_PATH);
SetLastError(ERROR_SUCCESS);
do {
GetModuleFileNameW(NULL, filename.data(), filename.size());
// Double the buffer size in case the path is longer
filename.resize(filename.size() * 2);
} while (GetLastError() == ERROR_INSUFFICIENT_BUFFER);
if (GetLastError() != ERROR_SUCCESS) {
return std::vector<uint8_t>();
}
DWORD file_ver_info_size = GetFileVersionInfoSizeW(filename.data(), &zero);
if (file_ver_info_size == 0) {
return std::vector<uint8_t>();
}
std::vector<uint8_t> file_ver_info(file_ver_info_size);
if (!GetFileVersionInfoW(filename.data(), NULL, file_ver_info.size(), file_ver_info.data())) {
return std::vector<uint8_t>();
}
return file_ver_info;
}
void print_help(VS_FIXEDFILEINFO* file_info) {
fprintf(stdout,
"Rcedit " RCEDIT_VERSION ": Edit resources of exe.\n\n"
"Rcedit %d.%d.%d: Edit resources of exe.\n\n"
"Usage: rcedit <filename> [options...]\n\n"
"Options:\n"
" -h, --help Show this message\n"
@@ -24,7 +56,10 @@ void print_help() {
" --application-manifest <path-to-file> Set manifest file\n"
" --set-resource-string <key> <value> Set resource string\n"
" --get-resource-string <key> Get resource string\n"
" --set-rcdata <key> <path-to-file> Replace RCDATA by integer id\n");
" --set-rcdata <key> <path-to-file> Replace RCDATA by integer id\n",
(file_info->dwProductVersionMS >> 16) & 0xff,
(file_info->dwProductVersionMS >> 0) & 0xff,
(file_info->dwProductVersionLS >> 16) & 0xff);
}
bool print_error(const char* message) {
@@ -54,7 +89,15 @@ int wmain(int argc, const wchar_t* argv[]) {
if (argc == 1 ||
(argc == 2 && wcscmp(argv[1], L"-h") == 0) ||
(argc == 2 && wcscmp(argv[1], L"--help") == 0)) {
print_help();
UINT ignored = 0;
VS_FIXEDFILEINFO* file_info = nullptr;
std::vector<uint8_t> file_version_info = get_file_version_info();
if (file_version_info.size() == 0 || !VerQueryValueW(file_version_info.data(), L"\\", (LPVOID*) &file_info, &ignored)) {
return print_error("Could not determine version of rcedit");
}
print_help(file_info);
return 0;
}
+4 -4
View File
@@ -20,8 +20,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,1,0
PRODUCTVERSION 1,1,1,0
FILEVERSION 0,0,0,0
PRODUCTVERSION 0,0,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -38,10 +38,10 @@ BEGIN
BEGIN
VALUE "CompanyName", "GitHub, Inc"
VALUE "FileDescription", "Edit resources of exe"
VALUE "FileVersion", "1.1.1"
VALUE "FileVersion", "0.0.0"
VALUE "LegalCopyright", "Copyright (C) 2013 GitHub, Inc. All rights reserved."
VALUE "ProductName", "rcedit"
VALUE "ProductVersion", "1.1.1"
VALUE "ProductVersion", "0.0.0"
END
END
BLOCK "VarFileInfo"
-28
View File
@@ -1,28 +0,0 @@
// Copyright (c) 2017 GitHub, Inc. All rights reserved.
// Use of this source code is governed by MIT license that can be found in the
// LICENSE file.
#ifndef SRC_VERSION_H_
#define SRC_VERSION_H_
#define RCEDIT_MAJOR_VERSION 1
#define RCEDIT_MINOR_VERSION 1
#define RCEDIT_PATCH_VERSION 1
#ifndef RCEDIT_TAG
# define RCEDIT_TAG ""
#endif
#ifndef RCEDIT_STRINGIFY
#define RCEDIT_STRINGIFY(n) RCEDIT_STRINGIFY_HELPER(n)
#define RCEDIT_STRINGIFY_HELPER(n) #n
#endif
#define RCEDIT_VERSION_STRING RCEDIT_STRINGIFY(RCEDIT_MAJOR_VERSION) "." \
RCEDIT_STRINGIFY(RCEDIT_MINOR_VERSION) "." \
RCEDIT_STRINGIFY(RCEDIT_PATCH_VERSION) \
RCEDIT_TAG
#define RCEDIT_VERSION "v" RCEDIT_VERSION_STRING
#endif // SRC_VERSION_H_