Skip to content

Commit

Permalink
Add workflow for releasing (#1198)
Browse files Browse the repository at this point in the history
This work adds a manually-triggered GHA workflow for creating a draft release on GitHub. Once the automated build completes successfully, a release manager should manually edit the release draft and publish it.

Existing CMake- and GHA-related have been cleaned up a bit.

* Remove *.sha256 file generation.
* Add CMake script to extract and print project version.
* Add separate workflow for releases.
* "name" of check.yaml build.yaml were changed to not include "CI /" as these workflows are now reused.
* "amalgamate" job moved into check.yaml as it's meant for checking/testing.
* Remove headers from dev packages.
* Remove lib package and rename dev to lib.
* Include .* files except .git/ in source package.
* Use WEBVIEW_VERSION for package version as PROJECT_VERSION doesn't include prerelease labels.
  • Loading branch information
SteffenL authored Oct 10, 2024
1 parent b19c598 commit c5b1940
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ runs:
name: package_${{ inputs.artifacts-name }}
path: |
${{ inputs.build-dir }}/*.gz
${{ inputs.build-dir }}/*.sha256
${{ inputs.build-dir }}/*.zip
retention-days: 1
if-no-files-found: error
Expand Down
File renamed without changes.
25 changes: 16 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
name: CI / Build
name: Build
on:
workflow_call:
inputs:
coverage:
type: boolean
description: Enable code coverage?
required: false
default: true
gcovr-version:
type: string
description: gcovr version
required: false
pr:
type: string
type: boolean
description: Is this a pull request build?
required: false
default: false
jobs:
load-matrix:
runs-on: ubuntu-22.04
Expand All @@ -23,7 +29,8 @@ jobs:
id: load-matrix
uses: actions/github-script@v7
env:
PR: ${{ inputs.pr != '' && fromJson(inputs.pr) }}
PR: ${{ inputs.pr }}
ENABLE_COVERAGE: ${{ inputs.coverage }}
with:
script: |
const csv = require("./.github/workflows/csv.js");
Expand All @@ -33,6 +40,7 @@ jobs:
// Filters
include = include.filter(x => JSON.parse(process.env.PR) === x["pr-only"]);
include = include.filter(x => x["job-type"] !== "coverage" || JSON.parse(process.env.ENABLE_COVERAGE));
const matrix = { include };
console.log(matrix);
Expand All @@ -50,7 +58,7 @@ jobs:
uses: actions/checkout@v4

- name: Set up environment
uses: ./.github/workflows/setup-env
uses: ./.github/actions/setup-env
with:
apt: ${{ matrix.apt }}
msys: ${{ matrix.msys }}
Expand Down Expand Up @@ -86,7 +94,6 @@ jobs:
// Packaging
option("WEBVIEW_ENABLE_PACKAGING", matrix["package"]),
option("WEBVIEW_PACKAGE_AMALGAMATION", matrix["package-amalgamation"]),
option("WEBVIEW_PACKAGE_DEV", matrix["package-dev"]),
option("WEBVIEW_PACKAGE_DOCS", matrix["package-docs"]),
option("WEBVIEW_PACKAGE_HEADERS", matrix["package-headers"]),
option("WEBVIEW_PACKAGE_LIB", matrix["package-lib"]),
Expand All @@ -96,7 +103,7 @@ jobs:
});
- name: CMake
uses: ./.github/workflows/cmake
uses: ./.github/actions/cmake
with:
artifacts-name: ${{ matrix.id }}
build-dir: build
Expand All @@ -107,9 +114,9 @@ jobs:
shell: ${{ matrix.shell }}
source-dir: .
test-wrapper-cmd: ${{ matrix.test-wrapper-cmd }}
upload-package-artifacts: ${{ matrix.package && (inputs.pr == '' || !fromJson(inputs.pr)) }}
upload-package-artifacts: ${{ matrix.package && !inputs.pr }}
# Specific to code coverage
coverage: ${{ matrix.job-type == 'coverage' }}
coverage: ${{ inputs.coverage && matrix.job-type == 'coverage' }}
gcov: ${{ matrix.gcov }}
gcovr-version: ${{ inputs.gcovr-version }}
upload-coverage-artifacts: ${{ matrix.job-type == 'coverage' && (inputs.pr == '' || !fromJson(inputs.pr)) }}
upload-coverage-artifacts: ${{ inputs.coverage && matrix.job-type == 'coverage' && !inputs.pr }}
108 changes: 54 additions & 54 deletions .github/workflows/build_matrix.csv

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .github/workflows/build_matrix_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"osx-deployment-target": "string",
"package": "boolean",
"package-amalgamation": "boolean",
"package-dev": "boolean",
"package-docs": "boolean",
"package-headers": "boolean",
"package-lib": "boolean",
Expand Down
38 changes: 37 additions & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI / Check
name: Check
on:
workflow_call:
jobs:
Expand All @@ -10,3 +10,39 @@ jobs:
- run: sudo apt-get install --no-install-recommends -y clang-format-15
- run: cmake -B build -S . -D WEBVIEW_BUILD=OFF -D WEBVIEW_CLANG_FORMAT_EXE=clang-format-15
- run: cmake --build build --target webview_format_check

amalgamate:
runs-on: ${{ matrix.image }}
strategy:
matrix:
image:
- macos-14
- ubuntu-22.04
- windows-2022
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
include:
- image: macos-14
clang-format-exe: clang-format
- image: ubuntu-22.04
clang-format-exe: clang-format-15
- image: windows-2022
clang-format-exe: clang-format
steps:
- uses: actions/checkout@v4
- if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y clang-format-15
- if: runner.os == 'macOS'
run: brew install clang-format
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: |
python3 scripts/amalgamate.py \
"--clang-format-exe=${{ matrix.clang-format-exe }}" \
--base core/include/webview \
--output webviev_amalgamation.h webview.h
shell: bash
60 changes: 10 additions & 50 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,36 @@ defaults:
run:
shell: bash
jobs:
check:
uses: ./.github/workflows/check.yaml

vars:
init:
runs-on: ubuntu-22.04
outputs:
gcovr-version: ${{ steps.vars.outputs.gcovr-version }}
steps:
- id: vars
run: |
echo "gcovr-version=7.2" >> "${GITHUB_OUTPUT}"
shell: bash
check:
uses: ./.github/workflows/check.yaml

build:
needs:
- check
- vars
- init
uses: ./.github/workflows/build.yaml
with:
gcovr-version: ${{ needs.vars.outputs.gcovr-version }}
gcovr-version: ${{ needs.init.outputs.gcovr-version }}

build-pr:
if: github.event_name == 'pull_request'
needs:
- check
- vars
- init
uses: ./.github/workflows/build.yaml
with:
gcovr-version: ${{ needs.vars.outputs.gcovr-version }}
gcovr-version: ${{ needs.init.outputs.gcovr-version }}
pr: true

amalgamate:
needs:
- check
- vars
runs-on: ${{ matrix.image }}
strategy:
matrix:
image:
- macos-14
- ubuntu-22.04
- windows-2022
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
include:
- image: macos-14
clang-format-exe: clang-format
- image: ubuntu-22.04
clang-format-exe: clang-format-15
- image: windows-2022
clang-format-exe: clang-format
steps:
- uses: actions/checkout@v4
- if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y clang-format-15
- if: runner.os == 'macOS'
run: brew install clang-format
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- run: |
python3 scripts/amalgamate.py \
"--clang-format-exe=${{ matrix.clang-format-exe }}" \
--base core/include/webview \
--output webviev_amalgamation.h webview.h
shell: bash
merge-package-artifacts:
needs: build
runs-on: ubuntu-22.04
Expand All @@ -89,7 +49,7 @@ jobs:
generate-coverage-report:
needs:
- build
- vars
- init
runs-on: ubuntu-22.04
steps:
- name: Checkout
Expand All @@ -104,7 +64,7 @@ jobs:
python3-pip
- name: Install gcovr
run: pip install "gcovr==${{ needs.vars.outputs.gcovr-version }}"
run: pip install "gcovr==${{ needs.init.outputs.gcovr-version }}"

- name: Merge test coverage artifacts
uses: actions/upload-artifact/merge@v4
Expand Down
98 changes: 98 additions & 0 deletions .github/workflows/draft-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Draft Release
on:
workflow_dispatch:
defaults:
run:
shell: bash
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
init:
runs-on: ubuntu-22.04
outputs:
gcovr-version: ${{ steps.vars.outputs.gcovr-version }}
release-tag: ${{ steps.vars.outputs.release-tag }}
steps:
- name: Checkout
uses: actions/checkout@v4

- id: vars
run: |
version="$(cmake -P cmake/extract_version.cmake)"
echo "gcovr-version=7.2" >> "${GITHUB_OUTPUT}"
echo "release-tag=${version}" >> "${GITHUB_OUTPUT}"
check:
uses: ./.github/workflows/check.yaml

build:
needs:
- check
- init
uses: ./.github/workflows/build.yaml
with:
coverage: false
gcovr-version: ${{ needs.init.outputs.gcovr-version }}

process-artifacts:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Merge package artifacts
uses: actions/upload-artifact/merge@v4
with:
name: package
pattern: package_*
delete-merged: true
retention-days: 1

- name: Download package artifacts
uses: actions/download-artifact@v4
with:
name: package
path: dist

- name: Create checksum file
run: sha256sum * > SHA256SUMS
working-directory: dist
shell: bash

- name: Upload checksum artifacts
uses: actions/upload-artifact@v4
with:
name: package_checksum
path: dist/*SUMS
retention-days: 1
if-no-files-found: error

create-github-release-draft:
needs:
- process-artifacts
- init
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download package artifacts
uses: actions/download-artifact@v4
with:
pattern: package*
path: dist
merge-multiple: true

- name: List artifacts
run: find dist/

- name: Verify checksums
run: sha256sum --check SHA256SUMS
working-directory: dist

- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.init.outputs.release-tag }}
run: gh release create --draft "${RELEASE_TAG}" dist/*
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,9 @@ Option | Description
`WEBVIEW_INSTALL_TARGETS` | Install targets
`WEBVIEW_IS_CI` | Initialized by the `CI` environment variable
`WEBVIEW_PACKAGE_AMALGAMATION` | Package amalgamated library
`WEBVIEW_PACKAGE_DEV` | Package development library
`WEBVIEW_PACKAGE_DOCS` | Package documentation
`WEBVIEW_PACKAGE_HEADERS` | Package headers
`WEBVIEW_PACKAGE_LIB` | Package release library
`WEBVIEW_PACKAGE_LIB` | Package compiled libraries
`WEBVIEW_STRICT_CHECKS` | Make checks strict
`WEBVIEW_STRICT_CLANG_FORMAT` | Make clang-format check strict
`WEBVIEW_STRICT_CLANG_TIDY` | Make clang-tidy check strict
Expand Down
6 changes: 6 additions & 0 deletions cmake/extract_version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Extracts the library's version number and prints it to stdout.

include("${CMAKE_CURRENT_LIST_DIR}/internal.cmake")
webview_extract_version()
# Need this workaround because message() prints to stderr
execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${WEBVIEW_VERSION}")
3 changes: 1 addition & 2 deletions cmake/internal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,9 @@ macro(webview_internal_options)
option(WEBVIEW_ENABLE_PACKAGING "Enable packaging" ${WEBVIEW_IS_TOP_LEVEL_BUILD})
option(WEBVIEW_STRICT_CHECKS "Make checks strict" ${WEBVIEW_IS_CI})
cmake_dependent_option(WEBVIEW_PACKAGE_AMALGAMATION "Package amalgamated library" ON WEBVIEW_ENABLE_PACKAGING OFF)
cmake_dependent_option(WEBVIEW_PACKAGE_DEV "Package development library" ON WEBVIEW_ENABLE_PACKAGING OFF)
cmake_dependent_option(WEBVIEW_PACKAGE_DOCS "Package documentation" ON WEBVIEW_ENABLE_PACKAGING OFF)
cmake_dependent_option(WEBVIEW_PACKAGE_HEADERS "Package headers" ON WEBVIEW_ENABLE_PACKAGING OFF)
cmake_dependent_option(WEBVIEW_PACKAGE_LIB "Package release library runtime" ON WEBVIEW_ENABLE_PACKAGING OFF)
cmake_dependent_option(WEBVIEW_PACKAGE_LIB "Package compiled libraries" ON WEBVIEW_ENABLE_PACKAGING OFF)
option(WEBVIEW_STRICT_CLANG_FORMAT "Make clang-format check strict" ${WEBVIEW_STRICT_CHECKS})
option(WEBVIEW_STRICT_CLANG_TIDY "Make clang-tidy check strict" ${WEBVIEW_STRICT_CHECKS})
endmacro()
Expand Down
Loading

0 comments on commit c5b1940

Please sign in to comment.