diff --git a/.github/workflows/release-testing.yaml b/.github/workflows/release-testing.yaml index 3cd8c0593c..a9d96a54c3 100644 --- a/.github/workflows/release-testing.yaml +++ b/.github/workflows/release-testing.yaml @@ -9,10 +9,102 @@ on: workflow_dispatch: permissions: - contents: read + contents: write packages: write jobs: + # Full build of the Mac assets + build-darwin: + runs-on: macos-12 + steps: + - uses: actions/checkout@v4 + - name: Set Version + shell: bash + run: | + echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV + echo "RELEASE_VERSION=${{ github.sha }}" >> $GITHUB_ENV + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + - name: Build Darwin + env: + SDKROOT: /Applications/Xcode_13.4.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk + DEVELOPER_DIR: /Applications/Xcode_13.4.1.app/Contents/Developer + run: | + ./scripts/build_darwin.sh + + - uses: actions/upload-artifact@v4 + with: + name: dist-darwin + path: | + dist/*arwin* + !dist/*-cov + + # Linux x86 assets built using the container based build + build-linux-amd64: + runs-on: ubuntu-latest + env: + PLATFORM: linux/amd64 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set Version + shell: bash + run: echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV + - run: | + ./scripts/build_linux.sh + - uses: actions/upload-artifact@v4 + with: + name: dist-linux-amd64 + path: | + dist/*linux* + !dist/*-cov + + # Linux ARM assets built using the container based build + # (at present, docker isn't pre-installed on arm ubunutu images) + build-linux-arm64: + runs-on: ollama01 + env: + PLATFORM: linux/arm64 + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set Version + shell: bash + run: echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV + - name: 'Install Docker' + run: | + # Add Docker's official GPG key: + env + uname -a + sudo apt-get update + sudo apt-get install -y ca-certificates curl + sudo install -m 0755 -d /etc/apt/keyrings + sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc + sudo chmod a+r /etc/apt/keyrings/docker.asc + + # Add the repository to Apt sources: + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + sudo usermod -aG docker $USER + sudo apt-get install acl + sudo setfacl --modify user:$USER:rw /var/run/docker.sock + - run: | + ./scripts/build_linux.sh + - uses: actions/upload-artifact@v4 + with: + name: dist-linux-arm64 + path: | + dist/*linux* + !dist/*-cov + build-container-image: strategy: matrix: @@ -141,3 +233,50 @@ jobs: - name: Inspect image run: | docker buildx imagetools inspect ${{ env.FINAL_IMAGE_REPO }}:${{ steps.meta.outputs.version }} + + # Aggregate all the assets and ship a release + release: + needs: + - build-darwin + - build-linux-amd64 + - build-linux-arm64 + runs-on: linux + permissions: + contents: write + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v4 + - name: Set Version + shell: bash + run: | + echo "VERSION=${{ github.sha }}" >> $GITHUB_ENV + echo "RELEASE_VERSION=${{ github.sha }}" >> $GITHUB_ENV + - name: Retrieve built artifact + uses: actions/download-artifact@v4 + with: + path: dist + pattern: dist-* + merge-multiple: true + - run: | + ls -lh dist/ + (cd dist; find . -type f | xargs sha256sum > ../sha256sum.txt) + mv sha256sum.txt dist/ + cat dist/sha256sum.txt + - name: Create or update Release + run: | + echo "Looking for existing release for ${{ env.RELEASE_VERSION }}" + OLD_TAG=$(gh release ls --json name,tagName | jq -r ".[] | select(.name == \"${{ env.RELEASE_VERSION }}\") | .tagName") + if [ -n "$OLD_TAG" ]; then + echo "Updating release ${{ env.RELEASE_VERSION }} to point to new tag ${{ github.sha }}" + gh release edit ${OLD_TAG} --tag ${{ github.sha }} + else + echo "Creating new release ${{ env.RELEASE_VERSION }} pointing to tag ${{ github.sha }}" + gh release create ${{ github.sha }} \ + --title ${{ env.RELEASE_VERSION }} \ + --draft \ + --generate-notes \ + --prerelease + fi + echo "Uploading artifacts for tag ${{ github.sha }}" + gh release upload ${{ github.sha }} dist/* --clobber