Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 5 additions & 14 deletions .github/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ ssh-agent -a ${SSH_AUTH_SOCK} > /dev/null
# Add private key to SSH agent
ssh-add - <<< "${SSH_KEY}"

# realpath does not exist on macOS
command -v realpath >/dev/null 2>&1 || realpath() {
[[ "$1" = /* ]] && echo "$1" || echo "${PWD}/${1#./}"
}

# sha256sum doesn't exist on Windows (Git Bash) or macOS
command -v sha256sum >/dev/null 2>&1 || sha256sum() {
openssl dgst -sha256 "$@" | sed 's/^SHA256(\(.*\))= \(\w\+\)$/\2 \1/'
}

for FILEPATH in "$@"
do
# Always upload to a temporary path.
Expand All @@ -44,10 +34,11 @@ do
FILENAME_HASH="${FILENAME}.sha256sum"
FILEPATH_HASH="${FILEPATH}.sha256sum"

# There should be no path components in the shasum file, so we need to cd to it first.
pushd "$(dirname "$(realpath "${FILEPATH}")")"
sha256sum "${FILENAME}" > "${FILENAME_HASH}"
popd
# The hash should be present already
if [ ! -f "$FILEPATH_HASH" ]; then
echo "Hash for artifact is missing: ${FILEPATH}"
echo "Did you forget to run 'generate_hash.sh' first?"
fi

FILEEXT="${FILENAME##*.}"

Expand Down
28 changes: 28 additions & 0 deletions .github/generate_hash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Generate hash for artifacts (e.g. dmg, deb files) built by CI to downloads.mixxx.org.

set -eu -o pipefail

# realpath does not exist on macOS
command -v realpath >/dev/null 2>&1 || realpath() {
[[ "$1" = /* ]] && echo "$1" || echo "${PWD}/${1#./}"
}

# sha256sum doesn't exist on Windows (Git Bash) or macOS
command -v sha256sum >/dev/null 2>&1 || sha256sum() {
openssl dgst -sha256 "$@" | sed 's/^SHA256(\(.*\))= \(\w\+\)$/\2 \1/'
}

for FILEPATH in "$@"
do
echo "Generating hash for artifact: ${FILEPATH}"
FILENAME="$(basename "${FILEPATH}")"
FILENAME_HASH="${FILENAME}.sha256sum"
FILEPATH_HASH="${FILEPATH}.sha256sum"

# There should be no path components in the shasum file, so we need to cd to it first.
pushd "$(dirname "$(realpath "${FILEPATH}")")"
sha256sum "${FILENAME}" > "${FILENAME_HASH}"
popd
done
73 changes: 68 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: Build

on:
push:
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branch:
- "[0-9].[0-9](\\-rel)?"
push:
branch:
- "[0-9].[0-9](\\-rel)?"

permissions:
contents: read # Fetch code (actions/checkout)
contents: write # Fetch code (actions/checkout), create release
packages: write # Upload and publish packages to GitHub Packages

jobs:
Expand Down Expand Up @@ -103,7 +107,7 @@ jobs:
- name: "[macOS] Bootstrap vcpkg"
if: runner.os == 'macOS'
run: |
brew update && brew install automake nasm autoconf-archive ${{ matrix.brew_extra }}
brew update && brew install nasm automake autoconf-archive coreutils ${{ matrix.brew_extra }}
sudo xcode-select --switch "$DEVELOPER_DIR"
xcrun --show-sdk-version

Expand Down Expand Up @@ -212,6 +216,12 @@ jobs:
pacman -S --noconfirm coreutils bash rsync openssh
Add-Content -Path "$Env:GITHUB_ENV" -Value "PATH=$Env:PATH"

- name: "Generate hash for artifacts"
if: github.event_name == 'push'
run: |
cd ${{ matrix.vcpkg_path }}
bash .github/generate_hash.sh ${{ env.DEPS_BASE_NAME }}-${{ env.MIXXX_VERSION }}-${{ matrix.deps_name }}-${{ steps.vars.outputs.sha_short }}.zip

- name: "Upload build to downloads.mixxx.org"
if: github.event_name == 'push' && env.SSH_PASSWORD != null
# Use retry loop to work around intermittent transfer issue
Expand All @@ -235,11 +245,64 @@ jobs:
SSH_USER: mixxx
UPLOAD_ID: ${{ github.run_id }}

- run: |
if ! gh release view --repo "${{ github.repository }}" "${RELEASE_NAME}" &> /dev/null
then
gh release create --repo "${{ github.repository }}" "${RELEASE_NAME}" \
--generate-notes \
--latest \
--target "${{ github.sha }}" ${{ !endsWith( github.event.ref, '-rel' ) && '--prerelease' || '' }}
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ env.MIXXX_VERSION }}-${{ steps.vars.outputs.sha_short }}
if: ${{ github.event_name == 'push' }}
id: ghrelease
shell: bash
name: "Creates a release in GitHub if it doesn't exist yet"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We normally have the name on top. You seems to have reverted the sort order of elements.
Please keep the normal sort order.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normal sort order

Does that mean just "name first" or is there some kind of bespoke ranking I should follow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if there is something like this.
It is just a good practice to follow the examples in the GitHub Docs:
https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions

- name:
  if:
  env:
  run: 

Copy link
Member Author

@acolombier acolombier Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure which example you are referring to. Only order I can find is the following:
image

It is just a good practice

Let's just agree to disagree here. However, I'm not willing to block this pressing optimisation over such a minor point. Here are the used keys:

  • run
  • env
  • if
  • id
  • shell
  • name

Please give me what order you want and I will update that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no strong demands in detail, but it shall be consistent with our other workflow for a good reading experience.

In https://github.com/mixxxdj/mixxx/blob/main/.github/workflows/build.yml we have:

  • name
  • id
  • if
  • uses
  • with
  • shell
  • run
  • working-directory
  • env (above if when required for if)


- run: |
split -b1536m -d "${VCPKG_FILENAME}" "${VCPKG_FILENAME}.part"
gh release upload --repo "${{ github.repository }}" "${RELEASE_NAME}" ${VCPKG_FILENAME}.*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VCPKG_FILENAME: ${{ env.DEPS_BASE_NAME }}-${{ env.MIXXX_VERSION }}-${{ matrix.deps_name }}-${{ steps.vars.outputs.sha_short }}.zip
RELEASE_NAME: ${{ env.MIXXX_VERSION }}-${{ steps.vars.outputs.sha_short }}
shell: bash
working-directory: ${{ matrix.vcpkg_path }}
if: runner.os != 'Windows' && steps.ghrelease.outcome == 'success'
name: "[MacOS] Creates assets and upload to GitHub release"

- run: |
$stream = [System.IO.File]::OpenRead("${{ matrix.vcpkg_path }}/${{ env.VCPKG_ASSET_PATH }}")
$chunkNum = 0
$bufSize = 1536MB
$barr = New-Object byte[] $bufSize

while( $bytesRead = $stream.Read($barr,0,$bufSize)){
$outFile = "${{ env.VCPKG_ASSET_PATH }}.part$chunkNum"
$ostream = [System.IO.File]::OpenWrite($outFile)
$ostream.Write($barr,0,$bytesRead);
$ostream.close();
echo "wrote $outFile"
$chunkNum += 1
}
gh release upload --repo "${{ github.repository }}" "${{ env.RELEASE_NAME }}" (get-item .\${{ env.VCPKG_ASSET_PATH }}.*).FullName "${{ matrix.vcpkg_path }}/${{ env.VCPKG_ASSET_PATH }}.sha256sum"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: ${{ env.MIXXX_VERSION }}-${{ steps.vars.outputs.sha_short }}
VCPKG_ASSET_PATH: ${{ env.DEPS_BASE_NAME }}-${{ env.MIXXX_VERSION }}-${{ matrix.deps_name }}-${{ steps.vars.outputs.sha_short }}.zip
if: runner.os == 'Windows' && steps.ghrelease.outcome == 'success'
name: "[Windows] Creates assets and upload to GitHub release"

- name: Upload GitHub Actions artifacts
if: ${{ steps.ghrelease.outcome == 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.DEPS_BASE_NAME }}-${{ env.MIXXX_VERSION }}-${{ matrix.deps_name }}-${{ steps.vars.outputs.sha_short }}
path: ${{ matrix.vcpkg_path }}/${{ env.DEPS_BASE_NAME }}-${{ env.MIXXX_VERSION }}-${{ matrix.deps_name }}-${{ steps.vars.outputs.sha_short }}.zip
path: |
${{ matrix.vcpkg_path }}/${{ env.DEPS_BASE_NAME }}-${{ env.MIXXX_VERSION }}-${{ matrix.deps_name }}-${{ steps.vars.outputs.sha_short }}.zip
${{ matrix.vcpkg_path }}/${{ env.DEPS_BASE_NAME }}-${{ env.MIXXX_VERSION }}-${{ matrix.deps_name }}-${{ steps.vars.outputs.sha_short }}.zip.sha256sum

# Workaround for https://github.com/actions/cache/issues/531
- name: Use system tar & zstd from Chocolatey for caching
Expand Down
Loading