Skip to content

Commit

Permalink
Enable automatic release on version change (#2829)
Browse files Browse the repository at this point in the history
* Use version file

This commit create a VERSION file that can be used to obtain the current
version of P4C.

The current version string "1.2.0+g202103291035~a69e52" contains a semantic
version, date and current git commit. However, the date makes sense only in
packages. Building the same P4C compiler code on a different day should not
result in a different version name. The current git commit is automatically
from the git history.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>

* ci: rename 'release' action to 'static-build'

This GitHub action doesn't create a release, it only tests if a static
build works on Ubuntu 20.04. Thus, using the name "static build" looks
more accurately describes what it does.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>

* Enable automatic releases

This GitHub action creates a release in GitHub every time
the Version.txt file has been changed.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
  • Loading branch information
rst0git authored Jun 29, 2021
1 parent 64eb44d commit df0ca8b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 19 deletions.
38 changes: 20 additions & 18 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
name: "release-p4c"
name: GitHub Release

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

branches:
- main
paths:
- 'Version.txt'
jobs:
# Build a p4c release on Ubuntu 16.04
build-linux:
strategy:
fail-fast: false
build:
runs-on: ubuntu-latest
env:
CTEST_PARALLEL_LEVEL: 4
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build (Linux)
run: |
tools/start_ccache
docker build --network ccache_network -t p4c --build-arg IMAGE_TYPE=build --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg BUILD_STATIC_RELEASE=ON --build-arg ENABLE_GMP=ON .
- name: Checkout
uses: actions/checkout@v2

- name: Get version
run: |
VERSION="v$(cat Version.txt)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/ci-static-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "static-build-test-p4c"

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
# Build a p4c release on Ubuntu 16.04
build-linux:
strategy:
fail-fast: false
runs-on: ubuntu-latest
env:
CTEST_PARALLEL_LEVEL: 4
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Build (Linux)
run: |
tools/start_ccache
docker build --network ccache_network -t p4c --build-arg IMAGE_TYPE=build --build-arg ENABLE_UNIFIED_COMPILATION=ON --build-arg BUILD_STATIC_RELEASE=ON --build-arg ENABLE_GMP=ON .
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ if (NOT $ENV{P4C_VERSION} STREQUAL "")
else()
# Semantic version numbering: <major>.<minor>.<patch>[-rcX]
# Examples: 0.5.1, 1.0.0-rc1, 1.0.1-alpha
set (P4C_SEM_VERSION_STRING "1.2.0+g202103291035~a69e52")
execute_process (COMMAND cat Version.txt
OUTPUT_VARIABLE P4C_SEM_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE rc
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
string (REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)([-0-9a-z\\.]*).*"
__p4c_version ${P4C_SEM_VERSION_STRING})
set (P4C_VERSION_MAJOR ${CMAKE_MATCH_1})
Expand Down
1 change: 1 addition & 0 deletions Version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.2.2

0 comments on commit df0ca8b

Please sign in to comment.