Skip to content

Commit 7b3a2c2

Browse files
authored
Changes for upcoming release (#43)
1 parent 7d835d5 commit 7b3a2c2

File tree

4 files changed

+178
-0
lines changed

4 files changed

+178
-0
lines changed

.github/workflows/release.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Release automation
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
commit_id:
7+
description: 'Commit ID to tag and create a release for'
8+
required: true
9+
version_number:
10+
description: 'Release Version Number (Eg, v1.0.0)'
11+
required: true
12+
delete_existing_tag_release:
13+
description: 'Is this a re-release of existing tag/release? (Default: false)'
14+
default: 'false'
15+
required: false
16+
jobs:
17+
clean-existing-tag-and-release:
18+
if: ${{ github.event.inputs.delete_existing_tag_release == 'true' }}
19+
runs-on: ubuntu-latest
20+
env:
21+
VERSION_NUM: ${{ github.event.inputs.version_number }}
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v2
26+
- name: Check if tag exists
27+
run: |
28+
git fetch origin
29+
if git tag --list $VERSION_NUM
30+
then
31+
echo "Deleting existing tag for $VERSION_NUM"
32+
git push origin --delete tags/$VERSION_NUM
33+
fi
34+
- name: Check if release exists
35+
run: |
36+
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
37+
sudo apt-add-repository https://cli.github.com/packages
38+
sudo apt update
39+
sudo apt-get install gh
40+
if gh release list | grep $VERSION_NUM
41+
then
42+
echo "Deleting existing release for $VERSION_NUM"
43+
gh release delete --yes $VERSION_NUM
44+
fi
45+
tag-commit:
46+
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
47+
needs: clean-existing-tag-and-release
48+
name: Tag commit
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout code
52+
uses: actions/checkout@v2
53+
with:
54+
ref: ${{ github.event.inputs.commit_id }}
55+
- name: Configure git identity
56+
run: |
57+
git config --global user.name "Release Workflow"
58+
- name: Tag Commit and Push to remote
59+
run: |
60+
git tag ${{ github.event.inputs.version_number }} -a -m "coreSNTP Library ${{ github.event.inputs.version_number }}"
61+
git push origin --tags
62+
- name: Verify tag on remote
63+
run: |
64+
git tag -d ${{ github.event.inputs.version_number }}
65+
git remote update
66+
git checkout tags/${{ github.event.inputs.version_number }}
67+
git diff ${{ github.event.inputs.commit_id }} tags/${{ github.event.inputs.version_number }}
68+
create-zip:
69+
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
70+
needs: tag-commit
71+
name: Create ZIP and verify package for release asset.
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Install ZIP tools
75+
run: sudo apt-get install zip unzip
76+
- name: Checkout code
77+
uses: actions/checkout@v2
78+
with:
79+
ref: ${{ github.event.inputs.commit_id }}
80+
path: coreSNTP
81+
submodules: recursive
82+
- name: Checkout disabled submodules
83+
run: |
84+
cd coreSNTP
85+
git submodule update --init --checkout --recursive
86+
- name: Create ZIP
87+
run: |
88+
zip -r coreSNTP-${{ github.event.inputs.version_number }}.zip coreSNTP -x "*.git*"
89+
ls ./
90+
- name: Validate created ZIP
91+
run: |
92+
mkdir zip-check
93+
mv coreSNTP-${{ github.event.inputs.version_number }}.zip zip-check
94+
cd zip-check
95+
unzip coreSNTP-${{ github.event.inputs.version_number }}.zip -d coreSNTP-${{ github.event.inputs.version_number }}
96+
ls coreSNTP-${{ github.event.inputs.version_number }}
97+
diff -r -x "*.git*" coreSNTP-${{ github.event.inputs.version_number }}/coreSNTP/ ../coreSNTP/
98+
cd ../
99+
- name: Build
100+
run: |
101+
cd zip-check/coreSNTP-${{ github.event.inputs.version_number }}/coreSNTP
102+
sudo apt-get install -y lcov
103+
cmake -S test -B build/ \
104+
-G "Unix Makefiles" \
105+
-DCMAKE_BUILD_TYPE=Debug \
106+
-DBUILD_UNIT_TESTS=ON \
107+
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -DNDEBUG'
108+
make -C build/ all
109+
- name: Test
110+
run: |
111+
cd zip-check/coreSNTP-${{ github.event.inputs.version_number }}/coreSNTP/build/
112+
ctest -E system --output-on-failure
113+
cd ..
114+
- name: Create artifact of ZIP
115+
uses: actions/upload-artifact@v2
116+
with:
117+
name: coreSNTP-${{ github.event.inputs.version_number }}.zip
118+
path: zip-check/coreSNTP-${{ github.event.inputs.version_number }}.zip
119+
create-release:
120+
if: ${{ ( github.event.inputs.delete_existing_tag_release == 'true' && success() ) || ( github.event.inputs.delete_existing_tag_release == 'false' && always() ) }}
121+
needs: create-zip
122+
name: Create Release and Upload Release Asset
123+
runs-on: ubuntu-latest
124+
steps:
125+
- name: Create Release
126+
id: create_release
127+
uses: actions/create-release@v1
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
with:
131+
tag_name: ${{ github.event.inputs.version_number }}
132+
release_name: ${{ github.event.inputs.version_number }}
133+
body: Release ${{ github.event.inputs.version_number }} of the coreSNTP Library.
134+
draft: false
135+
prerelease: false
136+
- name: Download ZIP artifact
137+
uses: actions/download-artifact@v2
138+
with:
139+
name: coreSNTP-${{ github.event.inputs.version_number }}.zip
140+
- name: Upload Release Asset
141+
id: upload-release-asset
142+
uses: actions/upload-release-asset@v1
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
with:
146+
upload_url: ${{ steps.create_release.outputs.upload_url }}
147+
asset_path: ./coreSNTP-${{ github.event.inputs.version_number }}.zip
148+
asset_name: coreSNTP-${{ github.event.inputs.version_number }}.zip
149+
asset_content_type: application/zip

manifest.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name : "coreSNTP"
2+
version: "v1.0.0"
3+
description: |
4+
"SNTP client library to allow embedded devices to synchronize time with time servers.\n"
5+
license: "MIT"

source/include/core_sntp_client.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@
5252
* defined in core_sntp_config.h file. */
5353
#include "core_sntp_config_defaults.h"
5454

55+
/* *INDENT-OFF* */
56+
#ifdef __cplusplus
57+
extern "C" {
58+
#endif
59+
/* *INDENT-ON* */
60+
5561
/**
5662
* @ingroup sntp_constants
5763
* @brief The default UDP port supported by SNTP/NTP servers for client-server
@@ -650,4 +656,10 @@ SntpStatus_t Sntp_ReceiveTimeResponse( SntpContext_t * pContext,
650656
const char * Sntp_StatusToStr( SntpStatus_t status );
651657
/* @[define_sntp_statustostr] */
652658

659+
/* *INDENT-OFF* */
660+
#ifdef __cplusplus
661+
}
662+
#endif
663+
/* *INDENT-ON* */
664+
653665
#endif /* ifndef CORE_SNTP_CLIENT_H_ */

source/include/core_sntp_serializer.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
#include <stdint.h>
3636
#include <stddef.h>
3737

38+
/* *INDENT-OFF* */
39+
#ifdef __cplusplus
40+
extern "C" {
41+
#endif
42+
/* *INDENT-ON* */
43+
3844
/**
3945
* @ingroup sntp_constants
4046
* @brief The base packet size of request and response of the (S)NTP protocol.
@@ -518,4 +524,10 @@ SntpStatus_t Sntp_ConvertToUnixTime( const SntpTimestamp_t * pSntpTime,
518524
uint32_t * pUnixTimeMicrosecs );
519525
/* @[define_sntp_converttounixtime] */
520526

527+
/* *INDENT-OFF* */
528+
#ifdef __cplusplus
529+
}
530+
#endif
531+
/* *INDENT-ON* */
532+
521533
#endif /* ifndef CORE_SNTP_SERIALIZER_H_ */

0 commit comments

Comments
 (0)