|
1 | | -# |
2 | | -# github.run_number is maintained per workflow file name. The workflow name may |
3 | | -# change without affecting the run_number counter, but when the file name changes, |
4 | | -# the counter is reset to one. This means that for each new version to have its |
5 | | -# own counter starting from one, the workflow need to be maintained per version |
6 | | -# and renamed for each new version. However, it gets worse, and while renaming |
7 | | -# the workflow file name in `master` resets the run counter and works well in |
8 | | -# tracking past and new builds on `master`, workflow files in other branches, |
9 | | -# like in branch `1-5` in this repository, are simply ignored, so the same |
10 | | -# technique won't work outside of `master`. |
11 | | -# |
12 | | -# Workflow name won't accept context expressions, such as ${{ github.run_number }}. |
13 | | -# |
14 | | -# Moreover, Actions UI confuses workflow names in different branches and while the |
15 | | -# name will be evaluated properly during the run (e.g. if ${{ github.workflow }} |
16 | | -# is used), the name of the running workflow will replace *all* run names in |
17 | | -# Actions UI, even for different branches, where workflow name is different. This |
18 | | -# makes it impossible to distinguish multiple runs without clicking on them, which |
19 | | -# would show the proper run name. Using per-branch workflow file name seems to be |
20 | | -# the only way around this. |
21 | | -# |
22 | | -name: Hello World 2.8.0 |
23 | | - |
24 | | -# manual and REST API runs only |
25 | | -on: |
26 | | - workflow_dispatch: |
27 | | - inputs: |
28 | | - TEST_INPUT: |
29 | | - description: Test input value |
30 | | - default: ABC |
31 | | - required: false |
32 | | -env: |
33 | | - # |
34 | | - # These version variables are half-measures for tracking build numbers and |
35 | | - # won't work as well as Azure pipeline names and counters. If this workflow |
36 | | - # file is reused between branches, build numbers will not be sequential and |
37 | | - # workflow runs will be messed up in Actions UI (see `name`). |
38 | | - # |
39 | | - # Seems that the only way to track build numbers per branch in GitHub is |
40 | | - # to rename workflow file name in each branch. |
41 | | - # |
42 | | - VERSION: 2.8.0 |
43 | | - BUILD_NUMBER: ${{ github.run_number }} |
44 | | - PKG_REV: ${{ github.event.inputs.PKG_REV }} |
45 | | - |
46 | | - # |
47 | | - # Environment mapping cannot be used within another env block, |
48 | | - # which requires juggling prefixes and suffixes that can be |
49 | | - # constructed at each level. If we wanted to construct a value |
50 | | - # from a version, matrix platform and input that can be reused |
51 | | - # between steps, we would need to construct a suffix from a |
52 | | - # matrix platform and input and then combine it with version |
53 | | - # where the full text is required. Alternatively, we can use |
54 | | - # format like this to make it more descriptive. |
55 | | - # |
56 | | - # version, platform |
57 | | - THREE_PART_VAR_FMT: '{0}/{1}/${{ github.event.inputs.TEST_INPUT }}' |
58 | | - |
59 | | -jobs: |
60 | | - test-matrix-job: |
61 | | - name: Test Matrix Job |
62 | | - runs-on: ubuntu-20.04 |
63 | | - strategy: |
64 | | - matrix: |
65 | | - build-platform: [x64, Win32] |
66 | | - build-config: [Debug, Release] |
67 | | - include: |
68 | | - - build-config: Release |
69 | | - release-only-var: This should appear only in a release build |
70 | | - |
71 | | - # |
72 | | - # Unlike Azure pipeline variables, evv mappings cannot refer |
73 | | - # to each other and this definition will generate errors. |
74 | | - # |
75 | | - #env: |
76 | | - # THREE_PART_VAR: '${{ env.VERSION }}/${{ matrix.build-platform }}/${{ github.event.inputs.TEST_INPUT }}' |
77 | | - |
78 | | - steps: |
79 | | - - name: Print vars |
80 | | - run: | |
81 | | - echo 'VARS: ${{ matrix.build-platform }} ${{ matrix.build-config }}' |
82 | | - echo 'RELEASE ONLY VAR: ${{ matrix.release-only-var }}' |
83 | | - echo 'THREE_PART_VAR_FMT: ${{ format(env.THREE_PART_VAR_FMT, env.VERSION, matrix.build-platform) }}' |
84 | | - echo 'THREE_PART_VAR: ${{ env.VERSION }}/${{ matrix.build-platform }}/${{ github.event.inputs.TEST_INPUT }}' |
85 | | -
|
86 | | - build-debian: |
87 | | - name: Debian Build |
88 | | - runs-on: ubuntu-20.04 |
89 | | - |
90 | | - steps: |
91 | | - # checkout the latest source |
92 | | - - name: Checkout |
93 | | - uses: actions/checkout@v2 |
94 | | - |
95 | | - # use a local action that builds a Debian container and runs `make` in it |
96 | | - - name: Make ./cpp |
97 | | - uses: ./.github/workflows/debian-build |
98 | | - with: |
99 | | - build_number: ${{ env.BUILD_NUMBER }} |
100 | | - |
101 | | - # run the app to make sure it was built |
102 | | - - name: test ./cpp |
103 | | - run: ./cpp |
104 | | - |
105 | | - # |
106 | | - # Use a local action to package build output as a tar/gzip artifact with |
107 | | - # the application version and build number in the archive name. |
108 | | - # |
109 | | - - name: Archive ./cpp |
110 | | - uses: ./.github/workflows/alpine-archive |
111 | | - with: |
112 | | - tar_gz_name: hello-world-deb-${{ env.VERSION }}+${{ env.BUILD_NUMBER }}.tar.gz |
113 | | - file_or_dir_path: ./cpp |
114 | | - |
115 | | - # upload the artifact under the `hello-world` name |
116 | | - - name: Upload ./cpp artifact |
117 | | - |
118 | | - with: |
119 | | - name: hello-world-deb |
120 | | - path: hello-world-deb-${{ env.VERSION }}+${{ env.BUILD_NUMBER }}.tar.gz |
121 | | - |
122 | | - build-windows: |
123 | | - name: Windows Build |
124 | | - runs-on: windows-2019 |
125 | | - strategy: |
126 | | - matrix: |
127 | | - build-platform: [x64, Win32] |
128 | | - include: |
129 | | - - build-platform: Win32 |
130 | | - vcvars-args: x86 |
131 | | - - build-platform: x64 |
132 | | - vcvars-args: x64 |
133 | | - |
134 | | - steps: |
135 | | - - name: Checkout |
136 | | - uses: actions/checkout@v2 |
137 | | - |
138 | | - # batch file must be prefixed with `call` for this step to work |
139 | | - - name: build cpp |
140 | | - shell: cmd |
141 | | - env: |
142 | | - VCVARS_ARGS: ${{ matrix.vcvars-args }} |
143 | | - run: | |
144 | | - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall" %VCVARS_ARGS% |
145 | | - cl /c /DBUILD_NUMBER=${{ env.BUILD_NUMBER }} test.cpp |
146 | | - link /OUT:cpp.exe /SUBSYSTEM:CONSOLE test.obj |
147 | | - |
148 | | - - name: test cpp |
149 | | - shell: cmd |
150 | | - run: cpp |
151 | | - |
152 | | - # 7zip is pre-loaded on Windows VMs |
153 | | - - name: Archive ./cpp.exe |
154 | | - shell: cmd |
155 | | - env: |
156 | | - PLATFORM: ${{ matrix.build-platform }} |
157 | | - run: | |
158 | | - 7z a -tzip hello-world-win-%PLATFORM%-%VERSION%+%BUILD_NUMBER%.zip ./cpp.exe |
159 | | - |
160 | | - # upload the artifact under the `hello-world` name |
161 | | - - name: Upload ./cpp artifact |
162 | | - |
163 | | - with: |
164 | | - name: hello-world-win-${{ matrix.build-platform }} |
165 | | - path: hello-world-win-${{ matrix.build-platform }}-${{ env.VERSION }}+${{ env.BUILD_NUMBER }}.zip |
166 | | - |
167 | | - release: |
168 | | - name: Create a draft release for ./cpp |
169 | | - needs: [build-debian, build-windows] |
170 | | - runs-on: ubuntu-latest |
171 | | - |
172 | | - steps: |
173 | | - # create a draft GitHub release |
174 | | - - name: Create a draft release |
175 | | - id: create_release |
176 | | - |
177 | | - env: |
178 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
179 | | - with: |
180 | | - tag_name: ${{ env.VERSION }} |
181 | | - release_name: v${{ env.VERSION }} |
182 | | - draft: true |
183 | | - |
184 | | - # download the artifact that was built in the `build` job in this workflow |
185 | | - - name: Download Debian artifact |
186 | | - |
187 | | - with: |
188 | | - name: hello-world-deb |
189 | | - path: . |
190 | | - |
191 | | - # upload the build artifact as a draft release asset |
192 | | - - name: Upload a Debian Release Asset |
193 | | - |
194 | | - env: |
195 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
196 | | - with: |
197 | | - # use the upload URL from the step that created a release |
198 | | - upload_url: ${{ steps.create_release.outputs.upload_url }} |
199 | | - asset_path: ./hello-world-deb-${{ env.VERSION }}+${{ env.BUILD_NUMBER }}.tar.gz |
200 | | - asset_name: hello-world-deb-${{ env.VERSION }}+${{ env.BUILD_NUMBER }}.tar.gz |
201 | | - asset_content_type: application/tar+gzip |
202 | | - |
203 | | - # same steps would be used for the x86 platform (not done in this script) |
204 | | - - name: Download Windows x64 artifact |
205 | | - |
206 | | - with: |
207 | | - name: hello-world-win-x64 |
208 | | - path: . |
209 | | - |
210 | | - - name: Upload a Windows Release Asset |
211 | | - |
212 | | - env: |
213 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
214 | | - with: |
215 | | - # use the upload URL from the step that created a release |
216 | | - upload_url: ${{ steps.create_release.outputs.upload_url }} |
217 | | - asset_path: ./hello-world-win-x64-${{ env.VERSION }}+${{ env.BUILD_NUMBER }}.zip |
218 | | - asset_name: hello-world-win-x64-${{ env.VERSION }}+${{ env.BUILD_NUMBER }}.zip |
219 | | - asset_content_type: application/zip |
| 1 | +name: Hello World 2.8.0 |
| 2 | + |
| 3 | +on: workflow_dispatch |
| 4 | + |
| 5 | +jobs: |
| 6 | + dummy-job: |
| 7 | + runs-on: ubuntu-20.04 |
| 8 | + steps: |
| 9 | + - run: echo done |
0 commit comments