@@ -2,7 +2,17 @@ name: build
22
33on :
44 workflow_call :
5+ inputs :
6+ version :
7+ description : " Version tag for release packaging"
8+ required : false
9+ type : string
510 workflow_dispatch :
11+ inputs :
12+ version :
13+ description : " Version tag for release packaging"
14+ required : false
15+ type : string
616
717concurrency :
818 group : build-${{ github.head_ref }}
@@ -34,23 +44,34 @@ jobs:
3444 with :
3545 persist-credentials : false
3646
37- - name : Prepare target
47+ - name : Prepare target and platform identifiers
3848 shell : bash
3949 env :
40- RUNNER_OS : ${{ runner.os }}
4150 PLATFORM_TARGET : ${{ matrix.platform.target }}
51+ RUNNER_OS : ${{ runner.os }}
4252 run : |
43- target="${ PLATFORM_TARGET} "
53+ target="$PLATFORM_TARGET"
4454
45- if [[ "${ RUNNER_OS} " == "Linux" ]]; then
55+ if [[ "$RUNNER_OS" == "Linux" ]]; then
4656 target+="-unknown-linux-gnu"
47- elif [[ "${RUNNER_OS}" == "macOS" ]]; then
57+ os="linux"
58+ elif [[ "$RUNNER_OS" == "macOS" ]]; then
4859 target+="-apple-darwin"
49- elif [[ "${RUNNER_OS}" == "Windows" ]]; then
60+ os="darwin"
61+ elif [[ "$RUNNER_OS" == "Windows" ]]; then
5062 target+="-pc-windows-msvc"
63+ os="windows"
64+ fi
65+
66+ if [[ "$PLATFORM_TARGET" == "x86_64" ]]; then
67+ arch="x64"
68+ elif [[ "$PLATFORM_TARGET" == "aarch64" ]]; then
69+ arch="arm64"
5170 fi
5271
5372 echo "TARGET=${target}" >> $GITHUB_ENV
73+ echo "OS=${os:-'unknown'}" >> $GITHUB_ENV
74+ echo "ARCH=${arch:-'unknown'}" >> $GITHUB_ENV
5475
5576 - uses : actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
5677 with :
6889 key : ${{ runner.os }}-zig-toolchain-${{ env.ZIG_VERSION }}
6990
7091 - name : Install Zig and cargo-zigbuild
71- if : ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' && steps.cache-zig. outputs.cache-hit != 'true' }}
92+ if : ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' && steps.cache-zig.outputs.cache-hit != 'true' }}
7293 shell : bash
7394 run : |
7495 wget -q "https://ziglang.org/download/${ZIG_VERSION}/zig-linux-x86_64-${ZIG_VERSION}.tar.xz"
@@ -78,75 +99,81 @@ jobs:
7899 - name : Add Zig to PATH
79100 if : ${{ runner.os == 'Linux' && matrix.platform.target == 'aarch64' }}
80101 shell : bash
81- run : echo "$PWD/zig-linux-x86_64-${ZIG_VERSION}" >> $GITHUB_PATH
102+ run : echo "${ PWD} /zig-linux-x86_64-${ZIG_VERSION}" >> $GITHUB_PATH
82103
83104 - name : Build release binary
84105 shell : bash
85106 env :
86107 RUNNER_OS : ${{ runner.os }}
87- PLATFORM_TARGET : ${{ matrix.platform.target }}
88- PLATFORM_RUNNER : ${{ matrix.platform.runner }}
89108 run : |
90- if [[ "${ RUNNER_OS} " == "Linux" && "${PLATFORM_TARGET} " == " aarch64" ]]; then
91- cargo zigbuild --release --target "${TARGET} "
109+ if [[ "$RUNNER_OS" == "Linux" && "$TARGET " == aarch64* ]]; then
110+ build_command="zigbuild "
92111 else
93- cargo build --verbose --release --target "${TARGET} "
112+ build_command="build "
94113 fi
95114
96- if [[ "${PLATFORM_RUNNER}" == windows-* ]]; then
115+ cargo "$build_command" --verbose --release --target "$TARGET"
116+
117+ if [[ "$RUNNER_OS" == "Windows" ]]; then
97118 bin="./target/${TARGET}/release/djls.exe"
98119 else
99120 bin="./target/${TARGET}/release/djls"
100121 fi
101122
102123 echo "BIN=${bin}" >> $GITHUB_ENV
103-
104- - name : Determine binary name
105- shell : bash
106- run : |
107- target="${TARGET}"
108- name="djls"
109-
110- if [[ "$target" == *linux* ]]; then
111- name+="-linux"
112- elif [[ "$target" == *apple* ]]; then
113- name+="-darwin"
114- elif [[ "$target" == *windows* ]]; then
115- name+="-windows"
116- fi
117-
118- if [[ "$target" == x86_64* ]]; then
119- name+="-x64"
120- elif [[ "$target" == aarch64* ]]; then
121- name+="-arm64"
122- fi
123-
124- if [[ "$target" == *windows* ]]; then
125- name+=".exe"
126- fi
127-
128- echo "BINARY_NAME=${name}" >> $GITHUB_ENV
124+ echo "ARTIFACT_PATH=${bin}" >> $GITHUB_ENV
129125
130126 - name : Strip release binary (Unix)
131127 if : ${{ runner.os != 'Windows' }}
132128 shell : bash
133129 env :
134130 RUNNER_OS : ${{ runner.os }}
135- PLATFORM_TARGET : ${{ matrix.platform.target }}
136131 run : |
137- if [[ "${ RUNNER_OS} " == "Linux" && "${PLATFORM_TARGET} " == " aarch64" ]]; then
132+ if [[ "$RUNNER_OS" == "Linux" && "$TARGET " == aarch64* ]]; then
138133 sudo apt-get update
139134 sudo apt-get install -y binutils-aarch64-linux-gnu
140- aarch64-linux-gnu-strip "${ BIN} "
135+ aarch64-linux-gnu-strip "$BIN"
141136 else
142- strip "${ BIN} "
137+ strip "$BIN"
143138 fi
144139
140+ - name : Create release archive
141+ if : ${{ inputs.version != '' }}
142+ shell : bash
143+ env :
144+ VERSION : ${{ inputs.version }}
145+ run : |
146+ archive="django-language-server-${VERSION}-${OS}-${ARCH}"
147+
148+ mkdir -p "$archive"
149+ cp "$BIN" "$archive/"
150+ cp README.md "$archive/"
151+ cp LICENSE "$archive/"
152+ cp CHANGELOG.md "$archive/"
153+
154+ echo "ARCHIVE=${archive}" >> $GITHUB_ENV
155+
156+ - name : Package for release (Windows)
157+ if : ${{ inputs.version != '' && runner.os == 'Windows' }}
158+ shell : bash
159+ run : |
160+ 7z a "${ARCHIVE}.zip" "$ARCHIVE"
161+ certutil -hashfile "${ARCHIVE}.zip" SHA256 > "${ARCHIVE}.zip.sha256"
162+ echo "ARTIFACT_PATH=${ARCHIVE}.zip*" >> $GITHUB_ENV
163+
164+ - name : Package for release (Unix)
165+ if : ${{ inputs.version != '' && runner.os != 'Windows' }}
166+ shell : bash
167+ run : |
168+ tar czf "${ARCHIVE}.tar.gz" "$ARCHIVE"
169+ shasum -a 256 "${ARCHIVE}.tar.gz" > "${ARCHIVE}.tar.gz.sha256"
170+ echo "ARTIFACT_PATH=${ARCHIVE}.tar.gz*" >> $GITHUB_ENV
171+
145172 - name : Upload binary
146173 uses : actions/upload-artifact@v4
147174 with :
148- name : binary-${{ env.BINARY_NAME }}
149- path : ${{ env.BIN }}
175+ name : binary-${{ env.OS }}-${{ env.ARCH }}
176+ path : ${{ env.ARTIFACT_PATH }}
150177
151178 linux :
152179 runs-on : ${{ matrix.platform.runner }}
@@ -343,3 +370,20 @@ jobs:
343370 with :
344371 name : wheels-sdist
345372 path : dist
373+
374+ attest :
375+ runs-on : ubuntu-latest
376+ if : ${{ inputs.version != '' }}
377+ needs : [binary, linux, musllinux, windows, macos, sdist]
378+ permissions :
379+ id-token : write
380+ attestations : write
381+ steps :
382+ - uses : actions/download-artifact@v5
383+
384+ - name : Generate artifact attestation
385+ uses : actions/attest-build-provenance@v3
386+ with :
387+ subject-path : |
388+ binary-*/*
389+ wheels-*/*
0 commit comments