Skip to content

Commit 79015aa

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 ab01108 commit 79015aa

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: .github/workflows/release-go-crosscompile-task.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ jobs:
9393
package-suffix: "macOS_ARM64.tar.gz"
9494

9595
steps:
96+
- name: Set environment variables
97+
run: |
98+
# See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
99+
echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV"
100+
96101
- name: Checkout repository
97102
uses: actions/checkout@v4
98103

@@ -136,7 +141,7 @@ jobs:
136141
run: |
137142
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
138143
# See: https://github.com/Bearer/gon#configuration-file
139-
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"]
144+
source = ["${{ env.DIST_DIR }}/${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"]
140145
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
141146
142147
sign {
@@ -165,11 +170,11 @@ jobs:
165170
run: |
166171
# GitHub's upload/download-artifact actions don't preserve file permissions,
167172
# so we need to add execution permission back until the action is made to do this.
168-
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"
173+
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
169174
TAG="${GITHUB_REF/refs\/tags\//}"
170175
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
171176
tar -czvf "$PACKAGE_FILENAME" \
172-
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/" "${{ env.PROJECT_NAME }}" \
177+
-C "${{ env.BUILD_FOLDER }}/" "${{ env.PROJECT_NAME }}" \
173178
-C ../../ LICENSE.txt
174179
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
175180

0 commit comments

Comments
 (0)