Skip to content

Commit 5d2f0a8

Browse files
authored
Create word artifact when a PR is merged to the main branch (#971)
* Generate the word doc as an artifact. Add a workflow to generate the word doc and upload it as an artifact. * updated deprecated commands. `::set-output` is being deprecated. Replace it with `status=` syntax. * Report status from converter run * add an id * YAML syntax * reorder steps * specify the shell * path fixes * remove unused array declaration This isn't used by the tool, it reads all files in the folder, so just remove it. Also, use the folder variable, rather than the hard-coded string.
1 parent 2d4e324 commit 5d2f0a8

File tree

6 files changed

+36
-30
lines changed

6 files changed

+36
-30
lines changed

.github/workflows/update-on-merge.yaml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ name: Update spec on merge
55
on:
66
push:
77
branches:
8-
- draft-v6
9-
- draft-v7
8+
- standard-v6
9+
- standard-v7
10+
- draft-v8
1011
workflow_dispatch:
1112
inputs:
1213
reason:
@@ -63,5 +64,23 @@ jobs:
6364
uses: peter-evans/[email protected]
6465
if: ${{ steps.renumber-sections.outputs.status }} == 'success' && ${{ steps.update-grammar.outputs.status }} == 'success'
6566
with:
66-
title: 'Automated Section renumber and grammar extraction'
67-
body: 'renumber sections. Add grammar'
67+
title: "Automated Section renumber and grammar extraction"
68+
body: "renumber sections. Add grammar"
69+
70+
- name: Run converter
71+
id: run-converter
72+
run: |
73+
cd tools
74+
./run-converter.sh
75+
shell: bash
76+
77+
- name: Upload Word artifact
78+
uses: actions/upload-artifact@v3
79+
if: >
80+
${{ steps.renumber-sections.outputs.status }} == 'success' &&
81+
${{ steps.update-grammar.outputs.status }} == 'success' &&
82+
${{ steps.run-converter.outputs.status }} == 'success'
83+
with:
84+
name: standard.docx
85+
path: ./tools/tmp/standard.docx
86+
retention-days: 15

tools/run-converter.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ dotnet run --project $CONVERTER_PROJECT -- \
2121
$SPEC_DIRECTORY/*.md $TEMPLATE \
2222
-o $OUTPUT_DIRECTORY/standard.docx
2323

24+
if [ "$?" -eq "0" ]
25+
then
26+
# Success: Write key/value for GitHub action to read:
27+
echo "status=success" >> $GITHUB_OUTPUT
28+
else
29+
# Failed: report the error to the GitHub action:
30+
echo "status=failed" >> $GITHUB_OUTPUT
31+
fi

tools/run-section-renumber.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ dotnet run --project $PROJECT -- $1
1414
if [ "$?" -eq "0" ]
1515
then
1616
# Success: Write key/value for GitHub action to read:
17-
echo "::set-output name=status::success"
17+
echo "status=success" >> $GITHUB_OUTPUT
1818
else
1919
# Failed: report the error to the GitHub action:
20-
echo "::set-output name=status::failed"
20+
echo "status=failed" >> $GITHUB_OUTPUT
2121
fi

tools/run-smarten.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ done
1717
rm -rf smarten
1818

1919
# I think always success, but echo the success output anyway:
20-
echo "::set-output name=status::success"
20+
echo "status=success" >> $GITHUB_OUTPUT

tools/update-grammar-annex.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ echo Insert EOF Stuff
4949
cat $GRAMMAR_PROJECT/grammar-eof-insert.md >>$OUTPUT_FILE
5050

5151
# I think always success, but echo the success output anyway:
52-
echo "::set-output name=status::success"
52+
echo "status=success" >> $GITHUB_OUTPUT

tools/validate-grammar.sh

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,7 @@ set -eu -o pipefail
33

44
declare -r SPEC_DIRECTORY=../standard
55

6-
declare -a SPEC_FILES=(
7-
"lexical-structure.md"
8-
"basic-concepts.md"
9-
"types.md"
10-
"variables.md"
11-
"conversions.md"
12-
"patterns.md"
13-
"expressions.md"
14-
"statements.md"
15-
"namespaces.md"
16-
"classes.md"
17-
"structs.md"
18-
"arrays.md"
19-
"interfaces.md"
20-
"enums.md"
21-
"delegates.md"
22-
"exceptions.md"
23-
"attributes.md"
24-
"unsafe-code.md"
25-
)
26-
27-
dotnet csharpgrammar ../test-grammar CSharp ../standard -m ../.github/workflows/dependencies/ReplaceAndAdd.md
6+
dotnet csharpgrammar ../test-grammar CSharp $SPEC_DIRECTORY -m ../.github/workflows/dependencies/ReplaceAndAdd.md
287

298
# Now, validate it:
309
curl -H "Accept: application/zip" https://repo1.maven.org/maven2/com/tunnelvisionlabs/antlr4/4.9.0/antlr4-4.9.0-complete.jar -o antlr-4.9.0-complete.jar

0 commit comments

Comments
 (0)