mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-01-30 10:35:37 +02:00
[cdc_rsync] Add build id to github workflow
This commit is contained in:
58
.github/workflows/create_release.yml
vendored
58
.github/workflows/create_release.yml
vendored
@@ -14,6 +14,30 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Use last commit hash as build version for the developer build.
|
||||||
|
if: "startsWith(github.ref, 'refs/heads/')"
|
||||||
|
run: echo "build_version=${GITHUB_SHA}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Use tag name as build version for the release build.
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
run: echo "build_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# This flow should not be used for pull requests. However the section
|
||||||
|
# below might be useful for testing purposes.
|
||||||
|
- name: Use last commit hash as build version for the pull request
|
||||||
|
if: startsWith(github.ref, 'refs/pull')
|
||||||
|
run: echo "build_version=${GITHUB_SHA}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Replace CDC_BUILD_VERSION
|
||||||
|
run: |
|
||||||
|
if grep -q "DCDC_BUILD_VERSION=DEV" "common/BUILD"; then
|
||||||
|
sed -i 's/DCDC_BUILD_VERSION=DEV/DCDC_BUILD_VERSION=${{ env.build_version }}/g' common/BUILD
|
||||||
|
else
|
||||||
|
echo "CDC_BUILD_VERSION was moved out from common/BUILD file."
|
||||||
|
echo "Please edit create_release.yaml workflow."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Initialize submodules
|
- name: Initialize submodules
|
||||||
run: git submodule update --init --recursive
|
run: git submodule update --init --recursive
|
||||||
|
|
||||||
@@ -58,6 +82,40 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Use last commit hash as build version for the developer build.
|
||||||
|
if: "startsWith(github.ref, 'refs/heads/')"
|
||||||
|
run: |
|
||||||
|
$build_version="${{ github.sha }}"
|
||||||
|
echo "build_version=$build_version" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Use tag name as build version for the release build.
|
||||||
|
if: "startsWith(github.ref, 'refs/tags/v')"
|
||||||
|
run: |
|
||||||
|
$build_version="${{ github.ref }}".replace("refs/tags/v", "")
|
||||||
|
echo "build_version=$build_version" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
|
# This flow should not be used for pull requests. However the section
|
||||||
|
# below might be useful for testing purposes.
|
||||||
|
- name: Use last commit hash as build version for the pull request
|
||||||
|
if: startsWith(github.ref, 'refs/pull')
|
||||||
|
run: |
|
||||||
|
$build_version="${{ github.sha }}"
|
||||||
|
echo "build_version=$build_version" >> $env:GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Replace CDC_BUILD_VERSION
|
||||||
|
run: |
|
||||||
|
$cdc_version = Select-String -Path common/BUILD -Pattern "DCDC_BUILD_VERSION=DEV"
|
||||||
|
if ($cdc_version -ne $null) {
|
||||||
|
$build_file = Get-Content -path common/BUILD -Raw
|
||||||
|
$build_file = $build_file -replace 'DCDC_BUILD_VERSION=DEV','DCDC_BUILD_VERSION=${{ env.build_version }}'
|
||||||
|
$build_file | Set-Content -Path common/BUILD
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Host "CDC_BUILD_VERSION was moved out from common/BUILD file."
|
||||||
|
Write-Host "Please edit create_release.yaml workflow."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
- name: Initialize submodules
|
- name: Initialize submodules
|
||||||
run: git submodule update --init --recursive
|
run: git submodule update --init --recursive
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,10 @@ cc_library(
|
|||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "build_version",
|
name = "build_version",
|
||||||
|
srcs = ["build_version.cc"],
|
||||||
hdrs = ["build_version.h"],
|
hdrs = ["build_version.h"],
|
||||||
|
# This definition should be replaced by release flow.
|
||||||
|
copts = ["-DCDC_BUILD_VERSION=DEV"],
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
|
|||||||
9
common/build_version.cc
Normal file
9
common/build_version.cc
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "build_version.h"
|
||||||
|
|
||||||
|
#ifdef CDC_BUILD_VERSION
|
||||||
|
#define TO_STR(arg) #arg
|
||||||
|
#define TO_STR_VALUE(arg) TO_STR(arg)
|
||||||
|
const char* BUILD_VERSION = TO_STR_VALUE(CDC_BUILD_VERSION);
|
||||||
|
#else
|
||||||
|
const char* BUILD_VERSION = DEV_BUILD_VERSION;
|
||||||
|
#endif
|
||||||
@@ -1,10 +1,7 @@
|
|||||||
#ifndef BUILD_VERSION
|
#ifndef COMMON_BUILD_VERSION_H_
|
||||||
|
#define COMMON_BUILD_VERSION_H_
|
||||||
|
|
||||||
#define DEV_BUILD_VERSION "DEV"
|
#define DEV_BUILD_VERSION "DEV"
|
||||||
#ifdef CDC_BUILD_VERSION
|
extern const char* BUILD_VERSION;
|
||||||
#define TO_STR(arg) #arg
|
|
||||||
#define TO_STR_VALUE(arg) TO_STR(arg)
|
#endif
|
||||||
#define BUILD_VERSION TO_STR_VALUE(CDC_BUILD_VERSION)
|
|
||||||
#else
|
|
||||||
#define BUILD_VERSION DEV_BUILD_VERSION
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@@ -124,9 +124,30 @@ TEST_F(GameletComponentTest, GetChangedComponents) {
|
|||||||
|
|
||||||
// Force equal timestamps, so that we don't depend on when the files were
|
// Force equal timestamps, so that we don't depend on when the files were
|
||||||
// actually written to everyone's drives.
|
// actually written to everyone's drives.
|
||||||
|
// Also force set build_version to developer since otherwise we would skip
|
||||||
|
// component size check.
|
||||||
ASSERT_EQ(components.size(), other_components.size());
|
ASSERT_EQ(components.size(), other_components.size());
|
||||||
for (size_t n = 0; n < components.size(); ++n) {
|
for (size_t n = 0; n < components.size(); ++n) {
|
||||||
other_components[n].modified_time = components[n].modified_time;
|
other_components[n].modified_time = components[n].modified_time;
|
||||||
|
other_components[n].build_version = DEV_BUILD_VERSION;
|
||||||
|
|
||||||
|
EXPECT_NE(components, other_components);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(GameletComponentTest, GetChangedComponents_BuildVersionChanged) {
|
||||||
|
std::vector<GameletComponent> components;
|
||||||
|
EXPECT_OK(GameletComponent::Get({valid_component_path_}, &components));
|
||||||
|
|
||||||
|
std::vector<GameletComponent> other_components;
|
||||||
|
EXPECT_OK(GameletComponent::Get({other_component_path_}, &other_components));
|
||||||
|
|
||||||
|
ASSERT_EQ(components.size(), other_components.size());
|
||||||
|
for (size_t n = 0; n < components.size(); ++n) {
|
||||||
|
other_components[n].modified_time = components[n].modified_time;
|
||||||
|
other_components[n].size = components[n].size;
|
||||||
|
components[n].build_version = "build_version";
|
||||||
|
other_components[n].build_version = "other_build_version";
|
||||||
|
|
||||||
EXPECT_NE(components, other_components);
|
EXPECT_NE(components, other_components);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user