|
1 | 1 | name: Release automation |
2 | 2 |
|
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + pull-requests: write |
| 6 | + |
3 | 7 | on: |
4 | 8 | workflow_dispatch: |
5 | 9 | inputs: |
6 | | - commit_id: |
7 | | - description: 'Commit ID to tag and create a release for' |
8 | | - required: true |
9 | 10 | version_number: |
10 | 11 | description: 'Release Version Number (Eg, v1.0.0)' |
11 | 12 | required: true |
12 | | - |
13 | | -# Workflow permissions block |
14 | | -permissions: |
15 | | - contents: write # This grants write access to repository content, including pushing commits/tags and creating releases. |
| 13 | + branch: |
| 14 | + description: 'Branch to release from' |
| 15 | + required: false |
| 16 | + default: 'main' |
16 | 17 |
|
17 | 18 | jobs: |
18 | | - tag-commit: |
19 | | - name: Tag commit |
20 | | - runs-on: ubuntu-latest |
21 | | - steps: |
22 | | - - name: Checkout code |
23 | | - uses: actions/checkout@v4 |
24 | | - with: |
25 | | - ref: ${{ github.event.inputs.commit_id }} |
26 | | - - name: Configure git identity |
27 | | - env: |
28 | | - ACTOR: ${{ github.actor }} |
29 | | - run: | |
30 | | - git config --global user.name "$ACTOR" |
31 | | - git config --global user.email "$ACTOR"@users.noreply.github.com |
32 | | - - name: create a new branch that references commit id |
33 | | - env: |
34 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
35 | | - COMMIT_ID: ${{ github.event.inputs.commit_id }} |
36 | | - run: git checkout -b "$VERSION_NUMBER" "$COMMIT_ID" |
37 | | - - name: Update version number in source files |
38 | | - env: |
39 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
40 | | - REPO_NAME: ${{ github.event.repository.name }} |
41 | | - source_folder_list: "source test" |
42 | | - run: | |
43 | | - echo "${{ env.source_folder_list }}" | \ |
44 | | - xargs -n 1 sh -c \ |
45 | | - 'find $1 -type f \( -name "*.c" -o -name "*.h" \) \ |
46 | | - -exec sed -i -b -E "0,/^ \* FreeRTOS\+TCP/s/^ \* FreeRTOS\+TCP.*/ \* FreeRTOS\+TCP $VERSION_NUMBER/g" {} +' |
47 | | - git add . |
48 | | - git commit -m '[AUTO][RELEASE]: Update version number in source files' |
49 | | - git push -u origin "$VERSION_NUMBER" |
50 | | - - name: Generate SBOM |
51 | | - uses: FreeRTOS/CI-CD-Github-Actions/sbom-generator@main |
52 | | - with: |
53 | | - repo_path: ./ |
54 | | - source_path: ./source |
55 | | - - name: commit SBOM file |
56 | | - env: |
57 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
58 | | - run: | |
59 | | - git add . |
60 | | - git commit -m 'Update SBOM' |
61 | | - git push -u origin "$VERSION_NUMBER" |
62 | | - - name: Tag Commit and Push to remote |
63 | | - env: |
64 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
65 | | - run: | |
66 | | - git tag "$VERSION_NUMBER" -a -m "FreeRTOS-Plus-TCP Library $VERSION_NUMBER" |
67 | | - git push origin --tags |
68 | | - - name: Verify tag on remote |
69 | | - env: |
70 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
71 | | - COMMIT_ID: ${{ github.event.inputs.commit_id }} |
72 | | - run: | |
73 | | - git tag -d "$VERSION_NUMBER" |
74 | | - git remote update |
75 | | - git checkout tags/"$VERSION_NUMBER" |
76 | | - git diff "$COMMIT_ID" tags/"$VERSION_NUMBER" |
77 | | - create-zip: |
78 | | - needs: tag-commit |
79 | | - name: Create ZIP and verify package for release asset. |
80 | | - runs-on: ubuntu-latest |
81 | | - steps: |
82 | | - - name: Install ZIP tools |
83 | | - run: sudo apt-get install zip unzip |
84 | | - - name: Checkout code |
85 | | - uses: actions/checkout@v4 |
86 | | - with: |
87 | | - ref: ${{ github.event.inputs.version_number }} |
88 | | - path: FreeRTOS-Plus-TCP |
89 | | - submodules: recursive |
90 | | - - name: Checkout disabled submodules |
91 | | - run: | |
92 | | - cd FreeRTOS-Plus-TCP |
93 | | - git submodule update --init --checkout --recursive |
94 | | - - name: Create ZIP |
95 | | - env: |
96 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
97 | | - run: | |
98 | | - zip -r FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip FreeRTOS-Plus-TCP -x "*.git*" |
99 | | - ls ./ |
100 | | - - name: Validate created ZIP |
101 | | - env: |
102 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
103 | | - run: | |
104 | | - mkdir zip-check |
105 | | - mv FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip zip-check |
106 | | - cd zip-check |
107 | | - unzip FreeRTOS-Plus-TCP-"$VERSION_NUMBER".zip -d FreeRTOS-Plus-TCP-"$VERSION_NUMBER" |
108 | | - ls FreeRTOS-Plus-TCP-"$VERSION_NUMBER" |
109 | | - diff -r -x "*.git*" FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP/ ../FreeRTOS-Plus-TCP/ |
110 | | - cd ../ |
111 | | - - name: Build |
112 | | - env: |
113 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
114 | | - run: | |
115 | | - cd zip-check/FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP |
116 | | - sudo apt-get install -y lcov |
117 | | - sudo apt-get install unifdef |
118 | | - cmake -S test/unit-test -B test/unit-test/build/ |
119 | | - make -C test/unit-test/build/ all |
120 | | - - name: Test |
121 | | - env: |
122 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
123 | | - run: | |
124 | | - cd zip-check/FreeRTOS-Plus-TCP-"$VERSION_NUMBER"/FreeRTOS-Plus-TCP |
125 | | - pushd test/unit-test/build/ |
126 | | - ctest -E system --output-on-failure |
127 | | - popd |
128 | | - make -C test/unit-test/build/ coverage |
129 | | - lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info |
130 | | - cd .. |
131 | | - - name: Create artifact of ZIP |
132 | | - uses: actions/upload-artifact@v4 |
133 | | - with: |
134 | | - name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip |
135 | | - path: zip-check/FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip |
136 | | - deploy-doxygen: |
137 | | - needs: tag-commit |
138 | | - name: Deploy doxygen documentation |
139 | | - runs-on: ubuntu-latest |
140 | | - steps: |
141 | | - - name: Doxygen generation |
142 | | - uses: FreeRTOS/CI-CD-Github-Actions/doxygen-generation@main |
143 | | - with: |
144 | | - ref: ${{ github.event.inputs.version_number }} |
145 | | - add_release: "true" |
146 | | - create-release: |
147 | | - permissions: |
148 | | - id-token: write |
149 | | - needs: |
150 | | - - create-zip |
151 | | - - deploy-doxygen |
152 | | - name: Create Release and Upload Release Asset |
153 | | - runs-on: ubuntu-latest |
154 | | - steps: |
155 | | - - name: Create Release |
156 | | - id: create_release |
157 | | - uses: actions/create-release@v1 |
158 | | - env: |
159 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
160 | | - with: |
161 | | - tag_name: ${{ github.event.inputs.version_number }} |
162 | | - release_name: ${{ github.event.inputs.version_number }} |
163 | | - body: Release ${{ github.event.inputs.version_number }} of the FreeRTOS-Plus-TCP Library. |
164 | | - draft: false |
165 | | - prerelease: false |
166 | | - - name: Download ZIP artifact |
167 | | - uses: actions/download-artifact@v4 |
168 | | - with: |
169 | | - name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip |
170 | | - - name: Upload Release Asset |
171 | | - id: upload-release-asset |
172 | | - uses: actions/upload-release-asset@v1 |
173 | | - env: |
174 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
175 | | - with: |
176 | | - upload_url: ${{ steps.create_release.outputs.upload_url }} |
177 | | - asset_path: ./FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip |
178 | | - asset_name: FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip |
179 | | - asset_content_type: application/zip |
180 | | - - name: Backup Release Asset |
181 | | - uses: FreeRTOS/CI-CD-Github-Actions/artifact-backup@main |
182 | | - with: |
183 | | - artifact_path: ./FreeRTOS-Plus-TCP-${{ github.event.inputs.version_number }}.zip |
184 | | - release_tag: ${{ github.event.inputs.version_number }} |
185 | | - cleanup: |
186 | | - needs: |
187 | | - - create-release |
188 | | - name: Cleanup |
| 19 | + release: |
| 20 | + name: Create Release |
189 | 21 | runs-on: ubuntu-latest |
190 | 22 | steps: |
191 | | - - name: Checkout code |
192 | | - uses: actions/checkout@v4 |
193 | | - - name: Delete branch created for Tag by SBOM generator |
194 | | - env: |
195 | | - VERSION_NUMBER: ${{ github.event.inputs.version_number }} |
196 | | - run: | |
197 | | - # Delete the branch created for Tag by SBOM generator |
198 | | - git push -u origin --delete refs/heads/"$VERSION_NUMBER" |
| 23 | + - name: Release |
| 24 | + uses: FreeRTOS/CI-CD-Github-Actions/release@main |
| 25 | + with: |
| 26 | + version_number: ${{ github.event.inputs.version_number }} |
| 27 | + branch: ${{ github.event.inputs.branch }} |
| 28 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + repo_build_command: rm -rf ../build && cmake -S. -B ../build -DSTANDALONE_TEST_BUILD_UNIX=1 && make -C ../build all |
| 30 | + run_test_command: 'sudo apt-get install -y lcov unifdef ninja-build && rm -rf ../build && cmake --fresh -G Ninja -S test/unit-test -B ../build/ -DBUILD_CLONE_SUBMODULES=1 -DSANITIZE=address,undefined && ninja -C ../build && ctest --test-dir ../build/ -E system --output-on-failure' |
0 commit comments