Skip to content

Commit 4e5bcdb

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 825da3a commit 4e5bcdb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ jobs:
9191
package-suffix: "macOS_ARM64.tar.gz"
9292

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

@@ -133,7 +137,7 @@ jobs:
133137
run: |
134138
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
135139
# See: https://github.com/Bearer/gon#configuration-file
136-
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"]
140+
source = ["${{ env.DIST_DIR }}/${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"]
137141
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
138142
139143
sign {
@@ -162,10 +166,10 @@ jobs:
162166
run: |
163167
# GitHub's upload/download-artifact actions don't preserve file permissions,
164168
# so we need to add execution permission back until the action is made to do this.
165-
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"
169+
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
166170
TAG="${GITHUB_REF/refs\/tags\//}"
167171
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
168-
tar -czvf "$PACKAGE_FILENAME" "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/"
172+
tar -czvf "$PACKAGE_FILENAME" "${{ env.BUILD_FOLDER }}/"
169173
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
170174
171175
- name: Upload artifact

0 commit comments

Comments
 (0)