Skip to content

Commit 0e961c8

Browse files
committed
Move definition of package filename to dedicated step in release workflow
The package filename is referenced in multiple places in the release workflow. In order to avoid code duplication, it is defined once as an environment variable, then that variable referenced in each of the instances where the filename is needed. Previously, this was done by first defining and referencing a shell environment variable at the point of the first usage, then defining a workflow environment variable and referencing that in the second usage. The maintainability and readability of the workflow is improved by using a single workflow environment variable, defined in the step dedicated to defining such variables, then referencing it consistently in all usages.
1 parent 1360076 commit 0e961c8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ jobs:
101101
run: |
102102
# See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
103103
echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV"
104+
TAG="${GITHUB_REF/refs\/tags\//}"
105+
echo "PACKAGE_FILENAME=${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}" >> $GITHUB_ENV
104106
105107
- name: Checkout repository
106108
uses: actions/checkout@v4
@@ -175,12 +177,9 @@ jobs:
175177
# GitHub's upload/download-artifact actions don't preserve file permissions,
176178
# so we need to add execution permission back until the action is made to do this.
177179
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
178-
TAG="${GITHUB_REF/refs\/tags\//}"
179-
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
180-
tar -czvf "$PACKAGE_FILENAME" \
180+
tar -czvf "${{ env.PACKAGE_FILENAME }}" \
181181
-C "${{ env.BUILD_FOLDER }}/" "${{ env.PROJECT_NAME }}" \
182182
-C ../../ LICENSE.txt
183-
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
184183
185184
- name: Upload artifact
186185
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)