Skip to content

Commit 02755fc

Browse files
committed
Use a more modular approach to tool installation in release workflow
The semver tool is used to identify pre-release tag versions and configure the GitHub release accordingly. Previously, the download, installation and use of the tool was all done in a single workflow step. Splitting these processes into three steps makes the identification of the cause of an error easier and also the related logs to facilitate the investigation.
1 parent ef5d8e6 commit 02755fc

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
release:
1414
runs-on: ubuntu-latest
1515

16+
env:
17+
# See: https://github.com/fsaintjacques/semver-tool/releases
18+
SEMVER_TOOL_VERSION: 3.2.0
19+
1620
steps:
1721
- name: Set environment variables
1822
run: |
@@ -21,6 +25,7 @@ jobs:
2125
echo "TAG_SHORT_NAME=$TAG_SHORT_NAME" >> "$GITHUB_ENV"
2226
echo "ARCHIVE_PATH=${{ runner.temp }}/libraries-repository-engine_${TAG_SHORT_NAME}_Linux_64bit.tar.gz" >> "$GITHUB_ENV"
2327
echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >> "$GITHUB_ENV"
28+
echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >> "$GITHUB_ENV"
2429
2530
- name: Checkout repository
2631
uses: actions/checkout@v2
@@ -58,20 +63,26 @@ jobs:
5863
case-insensitive-regex: true
5964
changelog-file-path: ${{ env.CHANGELOG_PATH }}
6065

61-
- name: Identify pre-releases
66+
- name: Download semver tool
67+
id: download-semver-tool
68+
uses: carlosperate/download-file-action@v1.0.3
69+
with:
70+
file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip
71+
location: ${{ runner.temp }}/semver-tool
72+
73+
- name: Install semver tool
74+
run: |
75+
unzip \
76+
-p \
77+
"${{ steps.download-semver-tool.outputs.file-path }}" \
78+
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \
79+
"${{ env.SEMVER_TOOL_PATH }}"
80+
chmod +x "${{ env.SEMVER_TOOL_PATH }}"
81+
82+
- name: Identify Prerelease
6283
id: prerelease
63-
env:
64-
# See: https://github.com/fsaintjacques/semver-tool/releases/latest
65-
TOOL_VERSION: 3.2.0
6684
run: |
67-
INSTALL_PATH="${{ runner.temp }}/semver-tool"
68-
mkdir -p "$INSTALL_PATH"
69-
wget --quiet --directory-prefix="$INSTALL_PATH" https://github.com/fsaintjacques/semver-tool/archive/${{ env.TOOL_VERSION }}.zip
70-
unzip -p "${INSTALL_PATH}/${{ env.TOOL_VERSION }}.zip" semver-tool-${{ env.TOOL_VERSION }}/src/semver >"${INSTALL_PATH}/semver"
71-
chmod +x "${INSTALL_PATH}/semver"
72-
if [[ $("${INSTALL_PATH}/semver" get prerel "${{ env.TAG_SHORT_NAME }}") ]]; then
73-
echo "::set-output name=is-pre::true";
74-
fi
85+
if [[ "$("${{ env.SEMVER_TOOL_PATH }}" get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
7586
7687
- name: Create Release
7788
uses: ncipollo/release-action@v1

0 commit comments

Comments
 (0)