Build #35
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
run-name: Build ${{ github.event.inputs.ref }} | |
on: | |
schedule: | |
- cron: '0 18 * * *' | |
- cron: '0 19 * * *' | |
- cron: '0 6 * * *' | |
- cron: '0 7 * * *' | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'Tag to build' | |
required: false | |
default: '' | |
permissions: | |
contents: write | |
jobs: | |
checks: | |
name: "Run checks" | |
runs-on: ubuntu-latest | |
outputs: | |
ref: ${{ steps.version_check.outputs.ref }} | |
build_flag: ${{ steps.version_check.outputs.build_flag }} | |
steps: | |
- name: Version check | |
id: version_check | |
run: | | |
input_ref="${{ github.event.inputs.ref }}" | |
zed_url="https://api.github.com/repos/zed-industries/zed/releases" | |
this_url="https://api.github.com/repos/pirafrank/zed_unofficial_win_builds/releases" | |
echo "Fetching latest non-draft releases from Zed repo..." | |
latest_stable_zed="$(curl -sL ${zed_url} | jq -r '[.[] | select(.prerelease == false and .draft == false)][0].tag_name')" | |
latest_pre_zed="$(curl -sL ${zed_url} | jq -r '[.[] | select(.prerelease == true and .draft == false)][0].tag_name')" | |
echo "Latest stable version: ${latest_stable_zed}" | |
echo "Latest pre-release: ${latest_pre_zed}" | |
echo "Fetching published versions for current repo..." | |
curl -sL ${this_url} | jq -r '.[].tag_name' > published_versions | |
# if input is not empty and not in published versions, use it | |
if [[ ! -z "${input_ref}" ]] ; then | |
echo "Input version provided: ${input_ref}" | |
if ! grep -Fxq "${input_ref}" published_versions ; then | |
echo "Version provided in input has not been published. Using ${input_ref}." | |
echo "ref=${input_ref}" >> $GITHUB_OUTPUT | |
echo "build_flag=true" >> $GITHUB_OUTPUT | |
else | |
echo "Version provided in input has already been published. Nothing to build." | |
echo "build_flag=false" >> $GITHUB_OUTPUT | |
fi | |
exit 0 | |
fi | |
echo "No input provided, checking the latest stable version." | |
if ! grep -Fxq "${latest_stable_zed}" published_versions ; then | |
echo "${latest_stable_zed} not published. Using it." | |
echo "ref=${latest_stable_zed}" >> $GITHUB_OUTPUT | |
echo "build_flag=true" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
echo "Latest stable version has already been published. Checking latest pre-release." | |
if ! grep -Fxq "${latest_pre_zed}" published_versions ; then | |
echo "${latest_pre_zed} not published. Using it." | |
echo "ref=${latest_pre_zed}" >> $GITHUB_OUTPUT | |
echo "build_flag=true" >> $GITHUB_OUTPUT | |
exit 0 | |
fi | |
echo "Nothing to build. All versions candidate to be built are already published." | |
echo "build_flag=false" >> $GITHUB_OUTPUT | |
build: | |
name: "Build Zed" | |
runs-on: windows-latest | |
needs: [checks] | |
if: ${{ needs.checks.outputs.build_flag == 'true' }} | |
outputs: | |
version: ${{ steps.extract_version.outputs.version }} | |
zed_zip_sha256: ${{ steps.checksum.outputs.zed_zip_sha256 }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
path: own | |
- name: Checkout Zed | |
shell: pwsh | |
run: | | |
git clone https://github.com/zed-industries/zed.git zed | |
cd zed | |
git checkout ${{ needs.checks.outputs.ref }} | |
- name: Check LongPathsEnabled first | |
run: | | |
(Get-ItemProperty "HKLM:System\CurrentControlSet\Control\FileSystem").LongPathsEnabled | |
- name: Enable long paths in Windows and in Git | |
shell: powershell | |
run: | | |
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force | |
git config --global core.longpaths true | |
- name: Check LongPathsEnabled after | |
run: | | |
(Get-ItemProperty "HKLM:System\CurrentControlSet\Control\FileSystem").LongPathsEnabled | |
- name: Extract toolchain channel | |
id: extract_toolchain | |
working-directory: ./zed | |
shell: bash | |
run: | | |
TOOLCHAIN_CHANNEL=$(grep 'channel' rust-toolchain.toml | cut -d '"' -f 2) | |
echo "Toolchain channel: $TOOLCHAIN_CHANNEL" | |
echo "TOOLCHAIN_CHANNEL=$TOOLCHAIN_CHANNEL" >> $GITHUB_OUTPUT | |
- name: Setup Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ steps.extract_toolchain.outputs.TOOLCHAIN_CHANNEL }} | |
target: "wasm32-wasip1" | |
components: "rustfmt, clippy" | |
- name: Show Rust toolchain info | |
run: | | |
rustc --version | |
rustup show | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v2 | |
with: | |
msbuild-architecture: x64 | |
- name: Install Windows 10 SDK | |
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2 | |
with: | |
sdk-version: 22000 | |
- name: Build project | |
working-directory: ./zed | |
shell: pwsh | |
# zed may be set to run the exe after the build, this | |
# won't work in an headless environment. The build at this | |
# point is likely to have completed successfully. | |
continue-on-error: true | |
run: | | |
cargo run --release | |
- name: Show build artifacts | |
working-directory: ./zed | |
shell: bash | |
run: | | |
ls -la target/release | |
- name: Check build artifacts | |
working-directory: ./zed | |
shell: bash | |
run: | | |
if [ ! -f ./target/release/zed.exe ]; then | |
echo "zed.exe not found. Build likely to have failed." | |
exit 1 | |
fi | |
- name: Compress build artifacts | |
working-directory: .\zed\target\release | |
shell: pwsh | |
run: | | |
Compress-Archive -Path zed.exe -Destination zed.zip | |
Compress-Archive -Path zed.pdb -Destination zed.pdb.zip | |
- name: Calculate SHA256 checksum | |
id: checksum | |
working-directory: ./zed/target/release | |
shell: bash | |
run: | | |
sha256sum zed.exe > zed.exe.sha256 | |
sha256sum zed.zip > zed.zip.sha256 | |
sha256sum zed.pdb.zip > zed.pdb.zip.sha256 | |
echo "zed_zip_sha256=$(cat zed.zip.sha256 | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT | |
- name: Extract clean version | |
id: extract_version | |
shell: bash | |
run: | | |
# version in release notes URL and in scoop bucket has no 'v' prefix, stripping | |
version="${{ needs.checks.outputs.ref }}" | |
if [[ "${version}" == v* ]]; then | |
version="${version:1}" | |
fi | |
echo "Extracted version: ${version}" | |
echo "version=${version}" >> $GITHUB_OUTPUT | |
- name: Create URL for release notes | |
id: rel_notes | |
shell: bash | |
run: | | |
version="${{ steps.extract_version.outputs.version }}" | |
# if version contains a hyphen, it is a pre-release | |
# pre-release versions have their own URL path on zed.dev | |
if [[ "${version}" == *-* ]]; then | |
# remove the hyphen and anything after it | |
version="${version%%-*}" | |
url="https://zed.dev/releases/preview/${version}" | |
else | |
url="https://zed.dev/releases/stable/${version}" | |
fi | |
echo "Relese Notes URL: ${url}" | |
echo url=${url}>> $GITHUB_OUTPUT | |
- name: Create release and upload assets | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
./zed/target/release/zed.zip | |
./zed/target/release/zed.exe.sha256 | |
./zed/target/release/zed.zip.sha256 | |
./zed/target/release/zed.pdb.zip | |
./zed/target/release/zed.pdb.zip.sha256 | |
name: ${{ needs.checks.outputs.ref }} | |
tag_name: ${{ needs.checks.outputs.ref }} | |
body: | | |
Release notes for `${{ needs.checks.outputs.ref }}` are available here: ${{ steps.rel_notes.outputs.url }} | |
generate_release_notes: false | |
draft: false | |
prerelease: ${{ contains(needs.checks.outputs.ref, 'pre') || contains(needs.checks.outputs.ref, '-') }} | |
# Note: drafts and prereleases cannot be set as latest. | |
make_latest: true | |
fail_on_unmatched_files: true | |
# no need to specify GITHUB_TOKEN here, it is automatically provided by GitHub Actions | |
# https://github.com/softprops/action-gh-release#-customizing | |
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication | |
scoop: | |
name: "Update scoop bucket" | |
runs-on: ubuntu-latest | |
needs: [checks, build] | |
# only commit to update the scoop bucket if built successfully and ref is not a pre-release | |
if: ${{ needs.build.result == 'success' && !contains(needs.checks.outputs.ref, 'pre') && !contains(needs.checks.outputs.ref, '-') }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Update scoop bucket | |
shell: bash | |
run: | | |
rm -f bucket/zed.json | |
cp -a bucket/zed.template.json bucket/zed.json | |
sed -i "s,VERSION_PLACEHOLDER,${{ needs.build.outputs.version }},g" bucket/zed.json | |
sed -i "s,SHA256_PLACEHOLDER,${{ needs.build.outputs.zed_zip_sha256 }},g" bucket/zed.json | |
# make a signed commit with changed to zed.json file | |
- name: Commit scoop bucket update | |
id: commit_changes | |
uses: pirafrank/github-commit-sign@v0 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
args: "commit --owner=${{ github.repository_owner }} --repo=${{ github.event.repository.name }} --branch=${{ github.ref_name }} --commitMessage='scoop bucket update for ${{ needs.checks.outputs.ref }}' --changed bucket/zed.json" |