Skip to content

Commit 892eafa

Browse files
authored
Use environment variable to define build folder name in release workflow (#35)
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 cb57fc9 commit 892eafa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ jobs:
8888
package-suffix: "macOS_ARM64.tar.gz"
8989

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

@@ -131,7 +136,7 @@ jobs:
131136
run: |
132137
cat > "${{ env.GON_CONFIG_PATH }}" <<EOF
133138
# See: https://github.com/Bearer/gon#configuration-file
134-
source = ["${{ env.DIST_DIR }}/${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}/${{ env.PROJECT_NAME }}"]
139+
source = ["${{ env.DIST_DIR }}/${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"]
135140
bundle_id = "cc.arduino.${{ env.PROJECT_NAME }}"
136141
137142
sign {
@@ -160,11 +165,10 @@ jobs:
160165
run: |
161166
# GitHub's upload/download-artifact actions don't preserve file permissions,
162167
# so we need to add execution permission back until the action is made to do this.
163-
PLATFORM_DIR="${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}"
164-
chmod +x "${PLATFORM_DIR}/${{ env.PROJECT_NAME }}"
168+
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
165169
TAG="${GITHUB_REF/refs\/tags\//}"
166170
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
167-
tar -czvf "$PACKAGE_FILENAME" "${PLATFORM_DIR}"
171+
tar -czvf "$PACKAGE_FILENAME" "${{ env.BUILD_FOLDER }}"
168172
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
169173
170174
- name: Upload artifact

0 commit comments

Comments
 (0)