Skip to content

Commit da50458

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 ec2c0c5 commit da50458

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ jobs:
8181
package-suffix: "macOS_ARM64.tar.gz"
8282

8383
steps:
84+
- name: Set environment variables
85+
run: |
86+
# See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
87+
echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV"
88+
8489
- name: Checkout repository
8590
uses: actions/checkout@v4
8691

@@ -124,7 +129,7 @@ jobs:
124129
run: |
125130
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
126131
# See: https://github.com/Bearer/gon#configuration-file
127-
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"]
132+
source = ["${{ env.DIST_DIR }}/${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"]
128133
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
129134
130135
sign {
@@ -154,10 +159,10 @@ jobs:
154159
run: |
155160
# GitHub's upload/download-artifact actions don't preserve file permissions,
156161
# so we need to add execution permission back until the action is made to do this.
157-
chmod +x "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"
162+
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
158163
TAG="${GITHUB_REF/refs\/tags\//}"
159164
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
160-
tar -czvf "$PACKAGE_FILENAME" "${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}"
165+
tar -czvf "$PACKAGE_FILENAME" "${{ env.BUILD_FOLDER }}"
161166
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
162167
163168
- name: Upload artifact

0 commit comments

Comments
 (0)