Skip to content

Commit

Permalink
ci: Fix use of parameter in conditionals (foundry-rs#4984)
Browse files Browse the repository at this point in the history
The boolean parameters were not used correctly leading to all builds
ending up being nightlies, even though they might have been tagged
releases.

Also all conditionals were normalized not to use explicit expression
syntax since that is not needed.
  • Loading branch information
tolbrino committed Sep 15, 2023
1 parent ae89c92 commit 733971f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ jobs:
- name: Finalize Docker Metadata
id: docker_tagging
run: |
if [[ "${{ github.event_name }}" == 'schedule' ]]; then
if [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "cron trigger, assigning nightly tag"
echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then
elif [[ "${GITHUB_REF##*/}" == "main" || "${GITHUB_REF##*/}" == "master" ]]; then
echo "manual trigger from master/main branch, assigning latest tag"
echo "docker_tags=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT
else
Expand Down
24 changes: 11 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
workflow_dispatch:

env:
IS_NIGHTLY: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
IS_NIGHTLY: ${{ github.event_name == 'schedule' || ( github.event_name == 'workflow_dispatch' && github.ref_type != 'tag' ) }}
CARGO_TERM_COLOR: always

jobs:
Expand All @@ -29,7 +29,7 @@ jobs:
- name: Compute release name and tag
id: release_info
run: |
if [[ $IS_NIGHTLY ]]; then
if $IS_NIGHTLY; then
echo "tag_name=nightly-${GITHUB_SHA}" >> $GITHUB_OUTPUT
echo "release_name=Nightly ($(date '+%Y-%m-%d'))" >> $GITHUB_OUTPUT
else
Expand All @@ -42,7 +42,7 @@ jobs:
# which allows users to roll back. It is also used to build
# the changelog.
- name: Create build-specific nightly tag
if: ${{ env.IS_NIGHTLY }}
if: env.IS_NIGHTLY == true
uses: actions/github-script@v5
env:
TAG_NAME: ${{ steps.release_info.outputs.tag_name }}
Expand All @@ -56,7 +56,7 @@ jobs:
uses: mikepenz/release-changelog-builder-action@v2
with:
configuration: "./.github/changelog.json"
fromTag: ${{ env.IS_NIGHTLY && 'nightly' || '' }}
fromTag: ${{ env.IS_NIGHTLY == true && 'nightly' || '' }}
toTag: ${{ steps.release_info.outputs.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -112,13 +112,13 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Apple M1 setup
if: ${{ matrix.job.target == 'aarch64-apple-darwin' }}
if: matrix.job.target == 'aarch64-apple-darwin'
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Linux ARM setup
if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }}
if: matrix.job.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-aarch64-linux-gnu
Expand All @@ -135,8 +135,7 @@ jobs:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
ARCH: ${{ matrix.job.arch }}
VERSION_NAME:
${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }}
VERSION_NAME: ${{ (env.IS_NIGHTLY == true && 'nightly') || needs.prepare.outputs.tag_name }}
shell: bash
run: |
if [ "$PLATFORM_NAME" == "linux" ]; then
Expand All @@ -156,12 +155,11 @@ jobs:
- name: Build man page
id: man
if: ${{ matrix.job.target == 'x86_64-unknown-linux-gnu' }}
if: matrix.job.target == 'x86_64-unknown-linux-gnu'
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
VERSION_NAME:
${{ (env.IS_NIGHTLY && 'nightly') || needs.prepare.outputs.tag_name }}
VERSION_NAME: ${{ (env.IS_NIGHTLY == true && 'nightly') || needs.prepare.outputs.tag_name }}
shell: bash
run: |
sudo apt-get -y install help2man
Expand Down Expand Up @@ -191,7 +189,7 @@ jobs:
# If this is a nightly release, it also updates the release
# tagged `nightly` for compatibility with `foundryup`
- name: Update nightly release
if: ${{ env.IS_NIGHTLY }}
if: env.IS_NIGHTLY == true
uses: softprops/action-gh-release@v1
with:
name: "Nightly"
Expand All @@ -212,7 +210,7 @@ jobs:

# Moves the `nightly` tag to `HEAD`
- name: Move nightly tag
if: ${{ env.IS_NIGHTLY }}
if: env.IS_NIGHTLY == true
uses: actions/github-script@v5
with:
script: |
Expand Down

0 comments on commit 733971f

Please sign in to comment.