Skip to content

Commit

Permalink
refactor: use step outputs intead of github env
Browse files Browse the repository at this point in the history
  • Loading branch information
scottyhardy committed Dec 17, 2021
1 parent 5d217a7 commit 1610719
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,26 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Extract wine version
id: wine_ver
env:
WINE_BRANCH: ${{ matrix.wine_branch }}
run: |
WINE_VER="$(docker run --rm docker-wine /bin/bash -c "dpkg -s wine-${WINE_BRANCH} \
| grep '^Version:\s' | awk '{print \$2}' | sed -E 's/~.*$//'" | tr -d "\r")"
if echo "${WINE_VER}" | grep -q -E "^[0-9]+(\.[0-9]+)+(-\S+)*$"; then
echo "Found wine version '${WINE_VER}'"
echo "wine_ver=${WINE_VER}" >> $GITHUB_ENV
echo "::set-output name=value::${WINE_VER}"
else
echo "ERROR: Unable to determine wine version"
exit 1
fi
-
name: Generate timestamp
id: timestamp
run: |
TIMESTAMP="$(date +"%Y%m%d")"
echo "Timestamp: ${TIMESTAMP}"
echo "timestamp=${TIMESTAMP}" >> $GITHUB_ENV
echo "::set-output name=value::${TIMESTAMP}"
-
name: Determine tags
uses: haya14busa/action-cond@v1
Expand All @@ -72,12 +74,12 @@ jobs:
if_true:
scottyhardy/docker-wine:latest,
scottyhardy/docker-wine:${{ matrix.wine_branch }},
scottyhardy/docker-wine:${{ matrix.wine_branch }}-${{ env.wine_ver }},
scottyhardy/docker-wine:${{ matrix.wine_branch }}-${{ env.wine_ver }}-${{ env.timestamp }}
scottyhardy/docker-wine:${{ matrix.wine_branch }}-${{ steps.wine_ver.outputs.value }},
scottyhardy/docker-wine:${{ matrix.wine_branch }}-${{ steps.wine_ver.outputs.value }}-${{ steps.timestamp.outputs.value }}
if_false:
scottyhardy/docker-wine:${{ matrix.wine_branch }},
scottyhardy/docker-wine:${{ matrix.wine_branch }}-${{ env.wine_ver }},
scottyhardy/docker-wine:${{ matrix.wine_branch }}-${{ env.wine_ver }}-${{ env.timestamp }}
scottyhardy/docker-wine:${{ matrix.wine_branch }}-${{ steps.wine_ver.outputs.value }},
scottyhardy/docker-wine:${{ matrix.wine_branch }}-${{ steps.wine_ver.outputs.value }}-${{ steps.timestamp.outputs.value }}
-
name: Build and push
id: docker_build
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/build_from_source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,19 @@ jobs:
run: mkdir -p wine-build/wine-install
-
name: Calculate previous stage number
id: previous_stage
if: matrix.stage > 1
run: |
PREV_STAGE=$(expr ${{ matrix.stage }} - 1)
echo "Previous stage number: '${PREV_STAGE}'"
echo "prev_stage=${PREV_STAGE}" >> $GITHUB_ENV
echo "::set-output name=value::${PREV_STAGE}"
-
name: Restore checkpoint cache
if: matrix.stage > 1
uses: actions/cache@v2
with:
path: wine-build
key: ${{ runner.os }}-${{ matrix.platform }}-${{ env.prev_stage }}-${{ github.run_id }}-${{ hashFiles('**/lockfiles') }}
key: ${{ runner.os }}-${{ matrix.platform }}-${{ steps.previous_stage.outputs.value }}-${{ github.run_id }}-${{ hashFiles('**/lockfiles') }}
-
name: Load CI builder image checkpoint
if: matrix.stage > 1
Expand Down Expand Up @@ -95,24 +96,26 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Extract wine version
id: wine_ver
if: matrix.stage == 3
run: |
git clone --depth=1 --shallow-submodules git://source.winehq.org/git/wine.git
WINE_VER="$(awk '{print $3}' wine/VERSION)"
if echo "${WINE_VER}" | grep -q -E "^[0-9]+(\.[0-9]+)+(-\S+)*$"; then
echo "Found wine version '${WINE_VER}'"
echo "wine_ver=${WINE_VER}" >> $GITHUB_ENV
echo "::set-output name=value::${WINE_VER}"
else
echo "ERROR: Unable to determine wine version"
exit 1
fi
-
name: Generate timestamp
id: timestamp
if: matrix.stage == 3
run: |
TIMESTAMP="$(date +"%Y%m%d")"
echo "Timestamp: ${TIMESTAMP}"
echo "timestamp=${TIMESTAMP}" >> $GITHUB_ENV
echo "::set-output name=value::${TIMESTAMP}"
-
name: Build final image and push
if: matrix.stage == 3
Expand All @@ -123,6 +126,6 @@ jobs:
push: true
tags:
scottyhardy/docker-wine:${{ matrix.platform }},
scottyhardy/docker-wine:devel-${{ env.wine_ver }}-${{ matrix.platform }},
scottyhardy/docker-wine:devel-${{ env.wine_ver }}-${{ matrix.platform }}-${{ env.timestamp }}
scottyhardy/docker-wine:devel-${{ steps.wine_ver.outputs.value }}-${{ matrix.platform }},
scottyhardy/docker-wine:devel-${{ steps.wine_ver.outputs.value }}-${{ matrix.platform }}-${{ steps.timestamp.outputs.value }}
target: ci-final
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ jobs:
tags: docker-wine:latest
-
name: Extract wine version
id: wine_ver
env:
WINE_BRANCH: ${{ matrix.wine_branch }}
run: |
WINE_VER="$(docker run --rm docker-wine /bin/bash -c "dpkg -s wine-${WINE_BRANCH} \
| grep '^Version:\s' | awk '{print \$2}' | sed -E 's/~.*$//'" | tr -d "\r")"
if echo "${WINE_VER}" | grep -q -E "^[0-9]+(\.[0-9]+)*$"; then
echo "Found wine version '${WINE_VER}'"
echo "WINE_VER=${WINE_VER}" >> $GITHUB_ENV
echo "::set-output name=value::${WINE_VER}"
else
echo "ERROR: Unable to determine wine version"
exit 1
Expand Down

0 comments on commit 1610719

Please sign in to comment.