Skip to content

Refactor variables in release workflows #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move definition of package filename to dedicated step in release work…
…flow

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.
  • Loading branch information
per1234 committed Nov 7, 2024
commit 0a33cec70e807ecb93f77e1cb6aacabdec7b451b
7 changes: 3 additions & 4 deletions .github/workflows/release-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ jobs:
run: |
# See: https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#setting-an-environment-variable
echo "BUILD_FOLDER=${{ env.PROJECT_NAME }}_osx_${{ matrix.build.folder-suffix }}" >> "$GITHUB_ENV"
TAG="${GITHUB_REF/refs\/tags\//}"
echo "PACKAGE_FILENAME=${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}" >> $GITHUB_ENV

- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -162,12 +164,9 @@ jobs:
# GitHub's upload/download-artifact actions don't preserve file permissions,
# so we need to add execution permission back until the action is made to do this.
chmod +x "${{ env.BUILD_FOLDER }}/${{ env.PROJECT_NAME }}"
TAG="${GITHUB_REF/refs\/tags\//}"
PACKAGE_FILENAME="${{ env.PROJECT_NAME }}_${TAG}_${{ matrix.build.package-suffix }}"
tar -czvf "$PACKAGE_FILENAME" \
tar -czvf "${{ env.PACKAGE_FILENAME }}" \
-C "${{ env.BUILD_FOLDER }}/" "${{ env.PROJECT_NAME }}" \
-C ../../ LICENSE.txt
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-artifact@v3
Expand Down
Loading