Skip to content

Commit 717db95

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
ATL-424: Generate a changelog for the nightlies.
Configure generated changelog output from `changelog` job so it can be used in the `release` job of the workflow It is necessary to define job outputs to make them accessible via the `needs` context in other jobs. Reference: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent 7536c3a commit 717db95

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,44 @@ jobs:
7777
name: build-artifacts
7878
path: electron/build/dist/build-artifacts/
7979

80-
publish:
80+
changelog:
8181
needs: build
82+
runs-on: ubuntu-latest
83+
outputs:
84+
BODY: ${{ steps.changelog.outputs.BODY }}
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v2
88+
with:
89+
fetch-depth: 0 # To fetch all history for all branches and tags.
90+
91+
- name: Generate Changelog
92+
id: changelog
93+
run: |
94+
export LATEST_TAG=$(git describe --abbrev=0)
95+
export GIT_LOG=$(git log --pretty=" - %s [%h]" $LATEST_TAG..HEAD | sed 's/ *$//g')
96+
export LATEST_TAG_WITH_LINK=$(echo "[$LATEST_TAG](https://github.com/arduino/arduino-pro-ide/releases/tag/$LATEST_TAG)")
97+
if [ -z "$GIT_LOG" ]; then
98+
export BODY="There were no changes since version $LATEST_TAG_WITH_LINK."
99+
else
100+
export BODY=$(echo -e "Changes since version $LATEST_TAG_WITH_LINK:\n$GIT_LOG")
101+
fi
102+
echo -e "$BODY"
103+
OUTPUT_SAFE_BODY="${BODY//'%'/'%25'}"
104+
OUTPUT_SAFE_BODY="${OUTPUT_SAFE_BODY//$'\n'/'%0A'}"
105+
OUTPUT_SAFE_BODY="${OUTPUT_SAFE_BODY//$'\r'/'%0D'}"
106+
echo "::set-output name=BODY::$OUTPUT_SAFE_BODY"
107+
echo "$BODY" > CHANGELOG.txt
108+
109+
- name: Upload Changelog [GitHub Actions]
110+
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master')
111+
uses: actions/upload-artifact@v2
112+
with:
113+
name: build-artifacts
114+
path: CHANGELOG.txt
115+
116+
publish:
117+
needs: changelog
82118
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master')
83119
runs-on: ubuntu-latest
84120
steps:
@@ -98,7 +134,7 @@ jobs:
98134
destination_dir: arduino-pro-ide/nightly/
99135

100136
release:
101-
needs: build
137+
needs: changelog
102138
if: startsWith(github.ref, 'refs/tags/')
103139
runs-on: ubuntu-latest
104140
steps:
@@ -108,21 +144,14 @@ jobs:
108144
name: build-artifacts
109145
path: build-artifacts
110146

111-
- name: Create Release [GitHub]
112-
uses: actions/create-release@v1
113-
env:
114-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115-
with:
116-
tag_name: ${{ github.ref }}
117-
release_name: ${{ github.ref }}
118-
119147
- name: Publish Release [GitHub]
120148
uses: svenstaro/upload-release-action@v1-release
121149
with:
122150
repo_token: ${{ secrets.GITHUB_TOKEN }}
123151
file: build-artifacts/*
124152
tag: ${{ github.ref }}
125153
file_glob: true
154+
body: ${{ needs.changelog.outputs.BODY }}
126155

127156
- name: Publish Release [S3]
128157
uses: kittaakos/upload-s3-action@v0.0.1

0 commit comments

Comments
 (0)