Skip to content

Commit 705c206

Browse files
committed
Use environment variable to define build folder name in release workflow
Multiple commands in the release workflow include the path of the folder that contains the build output. Previously, the complex folder name was specified redundantly in each instance. The readability and maintainability of the workflow is improved by using an environment variable to define the folder name in a single place, then referencing that environment variable in each of the individual commands that use the path.
1 parent 3cff836 commit 705c206

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/workflows/release-go-task.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ jobs:
8484
package-suffix: "macOS_ARM64.tar.gz"
8585

8686
steps:
87+
- name: Set environment variables
88+
run: |
89+
# See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
90+
echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV"
91+
8792
- name: Checkout repository
8893
uses: actions/checkout@v4
8994

@@ -127,7 +132,7 @@ jobs:
127132
run: |
128133
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
129134
# See: https://github.com/Bearer/gon#configuration-file
130-
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"]
135+
source = ["${{ env.DIST_DIR }}/${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"]
131136
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
132137
133138
sign {
@@ -156,11 +161,11 @@ jobs:
156161
run: |
157162
# GitHub's upload/download-artifact actions don't preserve file permissions,
158163
# so we need to add execution permission back until the action is made to do this.
159-
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"
164+
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
160165
TAG="${GITHUB_REF/refs\/tags\//}"
161166
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
162167
tar -czvf "$PACKAGE_FILENAME" \
163-
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
168+
-C "${{ env.BUILD_FOLDER }}/" "${{ env.PROJECT_NAME }}" \
164169
-C ../../ LICENSE.txt
165170
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
166171

0 commit comments

Comments
 (0)