Skip to content

Commit

Permalink
Merge pull request #23 from Tolc-Software/versions
Browse files Browse the repository at this point in the history
Add support for versioned releases
  • Loading branch information
srydell authored Feb 23, 2022
2 parents 9af1cbf + e8f3a8c commit feebd0f
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 159 deletions.
55 changes: 21 additions & 34 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:
branches:
- main

env:
BUILD_TYPE: Release

jobs:
build:

Expand All @@ -20,12 +17,6 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}

- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -54,42 +45,38 @@ jobs:
- name: Configure
run: |
cmake -S. -Bbuild -G Ninja -DCMAKE_CXX_COMPILER="/usr/local/opt/llvm/bin/clang++" -DCMAKE_C_COMPILER="/usr/local/opt/llvm/bin/clang" -DCMAKE_BUILD_TYPE="Release" -DENABLE_TESTING=ON -DENABLE_PACKAGING=ON
cmake -S. -Bbuild -G Ninja -DCMAKE_CXX_COMPILER="/usr/local/opt/llvm/bin/clang++" -DCMAKE_C_COMPILER="/usr/local/opt/llvm/bin/clang" -DCMAKE_BUILD_TYPE="Release" -DENABLE_TESTING=ON -DENABLE_PACKAGING=ON -DCPACK_PACKAGE_FILE_NAME=tolc
- name: Build
run: cmake --build build -j4

- name: Run tests
run: |
cd build
ctest --cores 4 --output-on-failure
- name: Build the release tar.gzip package
if: github.ref == 'refs/heads/main'
run: cpack -G TGZ --config build/CPackConfig.cmake
ctest --output-on-failure -j4
- name: Setup go
- name: Build the release tar.xz package
if: github.ref == 'refs/heads/main'
uses: actions/setup-go@v2
with:
go-version: '1.14'
run: cpack -G TXZ --config build/CPackConfig.cmake

- name: Setup go cache
if: github.ref == 'refs/heads/main'
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Push main release
- name: Push release
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
go get -v github.com/github-release/github-release
echo "Checking if a new release is needed"
github-release release --user Tolc-Software --repo tolc --tag main-release --name "Head release" --description "This release gets updated with each commit to main" || true
echo "Pushing the release"
github-release upload --user Tolc-Software --repo tolc --tag main-release --name "tolc-$(uname)-main.tar.gz" --file tolc-*.tar.gz --replace
# Move to keep the directory on Github Actions free from filename clashes
mv tolc.tar.xz tolc-Darwin-main.tar.xz
echo "Pushing to the latest tag"
gh release create latest --title "Latest release from main" --notes "This release gets updated on each commit to main" || true
gh release upload latest tolc-Darwin-main.tar.xz --clobber
version="$(cat docs/ReleaseNotes/version)"
# Move to keep the directory on Github Actions free from filename clashes
mv tolc-Darwin-main.tar.xz tolc-Darwin-${version}.tar.xz
echo "Making sure the release ${version} is online"
test -f docs/ReleaseNotes/${version}.md
gh release create "${version}" --title "${version}" --notes-file "docs/ReleaseNotes/${version}.md" || true
gh release upload "${version}" "tolc-Darwin-${version}.tar.xz" || true
52 changes: 18 additions & 34 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
pull_request:
branches: [ main ]

env:
BUILD_TYPE: Release

jobs:
build:

Expand All @@ -18,12 +15,6 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}

- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -52,45 +43,38 @@ jobs:
- name: Configure
run: |
cmake -S. -Bbuild -G Ninja -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_C_COMPILER="clang" -DCMAKE_BUILD_TYPE="Release" -DENABLE_TESTING=ON -DENABLE_PACKAGING=ON
cmake -S. -Bbuild -G Ninja -DCMAKE_CXX_COMPILER="clang++" -DCMAKE_C_COMPILER="clang" -DCMAKE_BUILD_TYPE="Release" -DENABLE_TESTING=ON -DENABLE_PACKAGING=ON -DCPACK_PACKAGE_FILE_NAME=tolc
- name: Build
run: cmake --build build -j4

- name: Run tests
run: |
cd build
ctest --cores 4 --output-on-failure
- name: Build the release tar.gzip package
if: github.ref == 'refs/heads/main'
run: cpack -G TGZ --config build/CPackConfig.cmake

- name: Setup go
if: github.ref == 'refs/heads/main'
uses: actions/setup-go@v2
with:
go-version: '1.14'
ctest --output-on-failure -j4
- name: Setup go cache
- name: Build the release tar.xz package
if: github.ref == 'refs/heads/main'
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
run: cpack -G TXZ --config build/CPackConfig.cmake

- name: Push main release
- name: Push release
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
go get -v github.com/github-release/github-release
echo "Checking if a new release is needed"
github-release release --user Tolc-Software --repo tolc --tag main-release --name "Head release" --description "This release gets updated with each commit to main" || true
echo "Pushing the release"
github-release upload --user Tolc-Software --repo tolc --tag main-release --name "tolc-$(uname)-main.tar.gz" --file tolc-*.tar.gz --replace
# Move to keep the directory on Github Actions free from filename clashes
mv tolc.tar.xz tolc-Linux.tar.xz
echo "Pushing to the latest tag"
gh release create latest --title "Latest release from main" --notes "This release gets updated on each commit to main" || true
gh release upload latest tolc-Linux.tar.xz --clobber
version="$(cat docs/ReleaseNotes/version)"
echo "Making sure the release ${version} is online"
test -f docs/ReleaseNotes/${version}.md
gh release create "${version}" --title "${version}" --notes-file "docs/ReleaseNotes/${version}.md" || true
gh release upload "${version}" tolc-Linux.tar.xz || true
- name: Deploy documentation to github-pages
if: github.ref == 'refs/heads/main'
Expand Down
51 changes: 21 additions & 30 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}

- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -67,37 +61,34 @@ jobs:
run: |
call "%VCVARS%"
cd build
ctest --cores 4 --output-on-failure
ctest --output-on-failure -j4
- name: Build the release tar.gzip package
- name: Build the release tar.xz package
if: github.ref == 'refs/heads/main'
shell: cmd
run: |
call "%VCVARS%"
cpack -G TGZ --config build/CPackConfig.cmake
- name: Setup go
if: github.ref == 'refs/heads/main'
uses: actions/setup-go@v2
with:
go-version: '1.14'

- name: Setup go cache
if: github.ref == 'refs/heads/main'
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
cpack -G TXZ --config build/CPackConfig.cmake
- name: Push main release
- name: Push release
if: github.ref == 'refs/heads/main'
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: |
go get -v github.com/github-release/github-release
echo "Checking if a new release is needed"
github-release release --user Tolc-Software --repo tolc --tag main-release --name "Head release" --description "This release gets updated with each commit to main" || true
echo "Pushing the release"
github-release upload --user Tolc-Software --repo tolc --tag main-release --name "tolc-Windows-main.tar.gz" --file tolc.tar.gz --replace
# Move to keep the directory on Github Actions free from filename clashes
mv tolc.tar.xz tolc-Windows-latest.tar.xz
echo "Pushing to the latest tag"
gh release create latest --title "Latest release from main" --notes "This release gets updated on each commit to main" || true
gh release upload latest tolc-Windows-latest.tar.xz --clobber
version="$(cat docs/ReleaseNotes/version)"
# Move to keep the directory on Github Actions free from filename clashes
mv tolc-Windows-latest.tar.xz tolc-Windows-${version}.tar.xz
echo "Making sure the release ${version} is online"
test -f docs/ReleaseNotes/${version}.md
gh release create "${version}" --title "${version}" --notes-file "docs/ReleaseNotes/${version}.md" || true
gh release upload "${version}" tolc-Windows-${version}.tar.xz || true
26 changes: 10 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ cmake_minimum_required(VERSION 3.17)

project(
tolc
VERSION 0.1
VERSION 0.2.0
LANGUAGES CXX)

configure_file(docs/ReleaseNotes/version.in
${CMAKE_CURRENT_LIST_DIR}/docs/ReleaseNotes/version @ONLY)

include(FetchContent)
FetchContent_Declare(
cmake_modules
Expand All @@ -27,23 +30,14 @@ include(${modules}/Sanitizers.cmake)

include(${modules}/StaticAnalyzers.cmake)

include(${modules}/GetFrontendpy.cmake)
set(frontendpy_asset_name "Frontend.py-${CMAKE_SYSTEM_NAME}-main")
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows)
set(frontendpy_asset_name "${frontendpy_asset_name}-${CMAKE_BUILD_TYPE}")
endif()
get_frontend_py(ASSET_NAME ${frontendpy_asset_name}.tar.xz)
copy_frontend_py_docs(SRC_DIR ${frontend_py_SOURCE_DIR})
include(${modules}/GetFrontend.cmake)
get_frontend(NAME Frontend.py VERSION v0.2.0)
copy_frontend_docs(NAME Frontend.py SRC_DIR ${frontend.py_SOURCE_DIR} COPY_TO
${CMAKE_CURRENT_LIST_DIR}/docs/packaging/docs/python)

include(${modules}/GetParser.cmake)
set(parser_asset_name "Parser-${CMAKE_SYSTEM_NAME}-main")
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Windows)
set(parser_asset_name "${parser_asset_name}-${CMAKE_BUILD_TYPE}")
endif()
get_parser(ASSET_NAME ${parser_asset_name}.tar.xz)
get_parser(VERSION v0.2.0)

# If we are not building from source we need to create some variables
# containing the paths to the included system library
# Set the include path for the system library in the variable
# We are using the standard library shipped
# with the downloaded llvm for include paths in the parsing
Expand Down Expand Up @@ -89,7 +83,7 @@ include(${modules}/ConanHelpers.cmake)
# Create the profile from variables known during configure
setup_conan_profile(VARIABLE tolc_conan_profile)

find_conan_packages(REQUIRES spdlog/1.8.0 fmt/7.1.3 PROFILE
find_conan_packages(REQUIRES spdlog/1.9.2 fmt/8.1.1 PROFILE
${tolc_conan_profile})

include(${modules}/GetBoost.cmake)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ $ python3
The prebuilt binaries are available under [the releases tab](https://github.com/Tolc-Software/tolc/releases/tag/main-release) in this repository. You may simply install them directly from there, or use `CMake` to download the binary for your platform directly:

```cmake
# Can be ["latest", "v0.2.0", ...]
set(tolc_version latest)
include(FetchContent)
FetchContent_Declare(
tolc_entry
URL https://github.com/Tolc-Software/tolc/releases/download/main-release/tolc-${CMAKE_HOST_SYSTEM_NAME}-main.tar.gz
URL https://github.com/Tolc-Software/tolc/releases/download/${tolc_version}/tolc-${CMAKE_HOST_SYSTEM_NAME}.tar.xz
)
FetchContent_Populate(tolc_entry)
Expand Down
2 changes: 2 additions & 0 deletions cmake/packaging/scripts/gather_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def main():
args = parseArguments()
print(args)

# Make sure the directory of the output exists
Path(args.combined_header).parent.mkdir(parents=True, exist_ok=True)
with open(args.combined_header, 'w') as output:
if not args.do_not_search_for_headers:
for include_directory in args.includes:
Expand Down
22 changes: 22 additions & 0 deletions docs/Release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Releases #

There are two types of releases for this project:

1. The `latest` release.
* Considered stable-ish.
* Built from each pull request merged and updated continuously.
2. Tagged releases (e.g. `v0.3.1`).
* Created each time a stable build is done.

## How to create a tagged release ##

1. Update the version number in `CMakeLists.txt`.
* This will, when building, populate the `VERSION` file in the root of this project.
2. Create the file `docs/ReleaseNotes/$(cat VERSION).md` containing the release notes and add it.
* This file will automatically be used as the release notes for that version.
* Ideally this file will be continuously updated as time goes on.
3. Create a pull request with the changes.
4. When passing and merged the following will happen:
* A new tag will be created as `$(cat VERSION)`
* A new github Release will be created from that tag
* The `cpack` generated file will be added to the release aswell as the `latest` release.
6 changes: 6 additions & 0 deletions docs/ReleaseNotes/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ignore all files named (wherever they are):
.DS_Store
.log

# Generated by CMake
version
9 changes: 9 additions & 0 deletions docs/ReleaseNotes/v0.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# News #

Initial versioned release!

## Features ##

* Most C++ constructs are automatically given a binding to python

See https://tolc.io for more information
1 change: 1 addition & 0 deletions docs/ReleaseNotes/v0.3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# News #
1 change: 1 addition & 0 deletions docs/ReleaseNotes/version.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v@CMAKE_PROJECT_VERSION@
11 changes: 5 additions & 6 deletions docs/packaging/docs/guides/translating_a_cpp_library.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ target_include_directories(Math PUBLIC include)
Below this code we download and install `tolc` locally into the project from [the release page](https://github.com/Tolc-Software/tolc/releases/tag/main-release)

```cmake
# CMakeLists.txt
# Can be ["latest", "v0.2.0", ...]
set(tolc_version latest)
include(FetchContent)
FetchContent_Declare(
tolc_entry
URL https://github.com/Tolc-Software/tolc/releases/download/main-release/tolc-${CMAKE_HOST_SYSTEM_NAME}-main.tar.gz
URL https://github.com/Tolc-Software/tolc/releases/download/${tolc_version}/tolc-${CMAKE_HOST_SYSTEM_NAME}.tar.gz
)
FetchContent_Populate(tolc_entry)
Expand All @@ -52,8 +53,7 @@ find_package(
CONFIG
PATHS
${tolc_entry_SOURCE_DIR}
REQUIRED
NO_DEFAULT_PATH)
REQUIRED)
```

After the call to `find_package` we are free to use the `CMake` functions available in the `tolc` installation. To create bindings for `Math` we have to call the `tolc_create_translation` function
Expand All @@ -63,8 +63,7 @@ After the call to `find_package` we are free to use the `CMake` functions availa
tolc_create_translation(
TARGET Math
LANGUAGE python
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python-bindings
)
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python-bindings)
```

This will read the public API of `Math`, create bindings to `python` and put them in `${CMAKE_CURRENT_BINARY_DIR}/python-bindings` (typically `build/python-bindings`). It also created the target `Math_python` (`<TARGET>_<LANGUAGE>`) for the bindings, and is just a normal build target. Configuring the project
Expand Down
Loading

0 comments on commit feebd0f

Please sign in to comment.