|
| 1 | +name: dev_releases |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 19 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + setup_ubuntu_x86_64: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + if: github.ref == 'refs/heads/main' |
| 12 | + steps: |
| 13 | + - name: Checkout repository |
| 14 | + uses: actions/checkout@v4 |
| 15 | + with: |
| 16 | + ref: 'refs/heads/dev' |
| 17 | + |
| 18 | + - name: Setup Python (x64) |
| 19 | + uses: actions/setup-python@v5 |
| 20 | + with: |
| 21 | + python-version: 3.x |
| 22 | + architecture: "x64" |
| 23 | + |
| 24 | + - name: Install Hatch |
| 25 | + run: pip install hatch |
| 26 | + |
| 27 | + - name: Create Hatch virtual environment for x86_64-linux |
| 28 | + run: hatch env create x86_64-unknown-linux-gnu |
| 29 | + |
| 30 | + - name: Build Release |
| 31 | + run: hatch run py_project_dev_tools make_exe_release_ci_cd --os_arch_line "x86_64-unknown-linux-gnu" |
| 32 | + |
| 33 | + - name: Upload artifact |
| 34 | + uses: actions/upload-artifact@v4 |
| 35 | + with: |
| 36 | + name: galena_x86_64-unknown-linux-gnu |
| 37 | + path: dist/galena_x86_64-unknown-linux-gnu.zip |
| 38 | + |
| 39 | + setup_ubuntu_aarch64: |
| 40 | + if: github.ref == 'refs/heads/main' |
| 41 | + runs-on: ubuntu-24.04-arm |
| 42 | + steps: |
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + ref: 'refs/heads/dev' |
| 47 | + |
| 48 | + - name: Setup Python (arm64) |
| 49 | + uses: actions/setup-python@v5 |
| 50 | + with: |
| 51 | + python-version: 3.x |
| 52 | + architecture: "arm64" |
| 53 | + |
| 54 | + - name: Install Hatch |
| 55 | + run: pip install hatch |
| 56 | + |
| 57 | + - name: Create Hatch virtual environment for aarch64-linux |
| 58 | + run: hatch env create aarch64-unknown-linux-gnu |
| 59 | + |
| 60 | + - name: Build Release |
| 61 | + run: hatch run py_project_dev_tools make_exe_release_ci_cd --os_arch_line "aarch64-unknown-linux-gnu" |
| 62 | + |
| 63 | + - name: Upload artifact |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: galena_aarch64-unknown-linux-gnu |
| 67 | + path: dist/galena_aarch64-unknown-linux-gnu.zip |
| 68 | + |
| 69 | + setup_windows_x86_64: |
| 70 | + if: github.ref == 'refs/heads/main' |
| 71 | + runs-on: windows-latest |
| 72 | + steps: |
| 73 | + - name: Checkout repository |
| 74 | + uses: actions/checkout@v4 |
| 75 | + with: |
| 76 | + ref: 'refs/heads/dev' |
| 77 | + |
| 78 | + - name: Setup Python (x64) |
| 79 | + uses: actions/setup-python@v5 |
| 80 | + with: |
| 81 | + python-version: 3.x |
| 82 | + architecture: "x64" |
| 83 | + |
| 84 | + - name: Install Hatch |
| 85 | + run: pip install hatch |
| 86 | + |
| 87 | + - name: Create Hatch virtual environment for x86_64-windows |
| 88 | + run: hatch env create x86_64-pc-windows-msvc |
| 89 | + |
| 90 | + - name: Build Release |
| 91 | + run: hatch run py_project_dev_tools make_exe_release_ci_cd --os_arch_line "x86_64-pc-windows-msvc" |
| 92 | + |
| 93 | + - name: Upload artifact |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: galena_x86_64-pc-windows-msvc |
| 97 | + path: dist/galena_x86_64-pc-windows-msvc.zip |
| 98 | + |
| 99 | + setup_windows_i686: |
| 100 | + if: github.ref == 'refs/heads/main' |
| 101 | + runs-on: windows-latest |
| 102 | + steps: |
| 103 | + - name: Checkout repository |
| 104 | + uses: actions/checkout@v4 |
| 105 | + with: |
| 106 | + ref: 'refs/heads/dev' |
| 107 | + |
| 108 | + - name: Setup Python (x86) |
| 109 | + uses: actions/setup-python@v5 |
| 110 | + with: |
| 111 | + python-version: 3.x |
| 112 | + architecture: "x86" |
| 113 | + |
| 114 | + - name: Install Hatch |
| 115 | + run: pip install hatch |
| 116 | + |
| 117 | + - name: Create Hatch virtual environment for i686-windows |
| 118 | + run: hatch env create i686-pc-windows-msvc |
| 119 | + |
| 120 | + - name: Build Release |
| 121 | + run: hatch run py_project_dev_tools make_exe_release_ci_cd --os_arch_line "i686-pc-windows-msvc" |
| 122 | + |
| 123 | + - name: Upload artifact |
| 124 | + uses: actions/upload-artifact@v4 |
| 125 | + with: |
| 126 | + name: galena_i686-pc-windows-msvc |
| 127 | + path: dist/galena_i686-pc-windows-msvc.zip |
| 128 | + |
| 129 | + bump_version: |
| 130 | + runs-on: ubuntu-latest |
| 131 | + needs: [setup_ubuntu_x86_64, setup_ubuntu_aarch64, setup_windows_x86_64, setup_windows_i686] |
| 132 | + steps: |
| 133 | + - name: Check out |
| 134 | + uses: actions/checkout@v4 |
| 135 | + with: |
| 136 | + token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" |
| 137 | + fetch-depth: 0 |
| 138 | + ref: 'refs/heads/dev' |
| 139 | + |
| 140 | + - name: Create bump and changelog |
| 141 | + uses: commitizen-tools/commitizen-action@master |
| 142 | + with: |
| 143 | + github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 144 | + changelog_increment_filename: body.md |
| 145 | + devrelease: ${{ github.run_id }} |
| 146 | + |
| 147 | + - name: Create version.txt |
| 148 | + run: | |
| 149 | + echo "Revision: ${{ env.REVISION }}" > version.txt |
| 150 | +
|
| 151 | + - name: Upload version.txt |
| 152 | + uses: actions/upload-artifact@v4 |
| 153 | + with: |
| 154 | + name: version.txt |
| 155 | + path: version.txt |
| 156 | + |
| 157 | + - name: Upload changelog body.md |
| 158 | + uses: actions/upload-artifact@v4 |
| 159 | + with: |
| 160 | + name: body.md |
| 161 | + path: body.md |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + setup_wheels_and_source_distributions: |
| 166 | + runs-on: ubuntu-latest |
| 167 | + outputs: |
| 168 | + wheel_artifact_name: ${{ steps.find_wheel.outputs.artifact_name }} |
| 169 | + sdist_artifact_name: ${{ steps.find_sdist.outputs.artifact_name }} |
| 170 | + needs: [bump_version] |
| 171 | + steps: |
| 172 | + - name: Checkout repository |
| 173 | + uses: actions/checkout@v4 |
| 174 | + with: |
| 175 | + ref: 'refs/heads/dev' |
| 176 | + |
| 177 | + - name: Setup Python (x64) |
| 178 | + uses: actions/setup-python@v5 |
| 179 | + with: |
| 180 | + python-version: 3.x |
| 181 | + architecture: "x64" |
| 182 | + |
| 183 | + - name: Install Hatch |
| 184 | + run: pip install hatch |
| 185 | + |
| 186 | + - name: Build Wheels and Source Distributions |
| 187 | + run: hatch build |
| 188 | + |
| 189 | + # - name: Publish Wheels and Source Distributions |
| 190 | + # run: hatch publish --repo "main" --user "__token__" --auth "${{ secrets.PYPI_PASSWORD }}" |
| 191 | + |
| 192 | + - name: Find wheel file |
| 193 | + id: find_wheel |
| 194 | + run: | |
| 195 | + WHEEL_PATH=$(find dist -name "*.whl" | head -n 1) |
| 196 | + WHEEL_NAME=$(basename "$WHEEL_PATH") |
| 197 | + ARTIFACT_NAME="${WHEEL_NAME%.whl}" |
| 198 | + echo "wheel_path=$WHEEL_PATH" >> "$GITHUB_OUTPUT" |
| 199 | + echo "artifact_name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" |
| 200 | +
|
| 201 | + - name: Upload python wheel artifact |
| 202 | + uses: actions/upload-artifact@v4 |
| 203 | + with: |
| 204 | + name: ${{ steps.find_wheel.outputs.artifact_name }} |
| 205 | + path: ${{ steps.find_wheel.outputs.wheel_path }} |
| 206 | + |
| 207 | + - name: Find sdist file |
| 208 | + id: find_sdist |
| 209 | + run: | |
| 210 | + SDIST_PATH=$(find dist -name "*.tar.gz" | head -n 1) |
| 211 | + SDIST_NAME=$(basename "$SDIST_PATH") |
| 212 | + ARTIFACT_NAME="${SDIST_NAME%.tar.gz}" |
| 213 | + echo "sdist_path=$SDIST_PATH" >> "$GITHUB_OUTPUT" |
| 214 | + echo "artifact_name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" |
| 215 | +
|
| 216 | + - name: Upload python sdist artifact |
| 217 | + uses: actions/upload-artifact@v4 |
| 218 | + with: |
| 219 | + name: ${{ steps.find_sdist.outputs.artifact_name }} |
| 220 | + path: ${{ steps.find_sdist.outputs.sdist_path }} |
| 221 | + |
| 222 | + setup_github_releases: |
| 223 | + runs-on: ubuntu-latest |
| 224 | + needs: [setup_wheels_and_source_distributions] |
| 225 | + steps: |
| 226 | + - name: Download ubuntu_x86_64_artifact |
| 227 | + uses: actions/download-artifact@v4 |
| 228 | + with: |
| 229 | + name: galena_x86_64-unknown-linux-gnu |
| 230 | + path: ./dist |
| 231 | + |
| 232 | + - name: Download ubuntu_aarch64_artifact |
| 233 | + uses: actions/download-artifact@v4 |
| 234 | + with: |
| 235 | + name: galena_aarch64-unknown-linux-gnu |
| 236 | + path: ./dist |
| 237 | + |
| 238 | + - name: Download windows_x86_64_artifact |
| 239 | + uses: actions/download-artifact@v4 |
| 240 | + with: |
| 241 | + name: galena_x86_64-pc-windows-msvc |
| 242 | + path: ./dist |
| 243 | + |
| 244 | + - name: Download windows_i686_artifact |
| 245 | + uses: actions/download-artifact@v4 |
| 246 | + with: |
| 247 | + name: galena_i686-pc-windows-msvc |
| 248 | + path: ./dist |
| 249 | + |
| 250 | + - name: Download windows_i686_artifact |
| 251 | + uses: actions/download-artifact@v4 |
| 252 | + with: |
| 253 | + name: galena_i686-pc-windows-msvc |
| 254 | + path: ./dist |
| 255 | + |
| 256 | + - name: Download python_wheel_artifact |
| 257 | + uses: actions/download-artifact@v4 |
| 258 | + with: |
| 259 | + name: ${{ needs.setup_wheels_and_source_distributions.outputs.wheel_artifact_name }} |
| 260 | + path: ./dist |
| 261 | + |
| 262 | + - name: Download python_sdist_artifact |
| 263 | + uses: actions/download-artifact@v4 |
| 264 | + with: |
| 265 | + name: ${{ needs.setup_wheels_and_source_distributions.outputs.sdist_artifact_name }} |
| 266 | + path: ./dist |
| 267 | + |
| 268 | + - name: Download version.txt artifact |
| 269 | + uses: actions/download-artifact@v4 |
| 270 | + with: |
| 271 | + name: version.txt |
| 272 | + |
| 273 | + - name: Read version from version.txt |
| 274 | + id: extract_version |
| 275 | + run: | |
| 276 | + # Read the contents of the downloaded version.txt file and extract the revision |
| 277 | + VERSION=$(cat version.txt | grep -oP 'Revision: \K.*') # Extract the version number after "Revision: " |
| 278 | + echo "Version extracted: $VERSION" |
| 279 | + echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" |
| 280 | +
|
| 281 | + - name: Rename artifacts with version suffix |
| 282 | + run: | |
| 283 | + VERSION="${{ steps.extract_version.outputs.version }}" |
| 284 | +
|
| 285 | + cd dist |
| 286 | +
|
| 287 | + for FILE in galena*.zip; do |
| 288 | + if [[ "$FILE" != *"$VERSION"* ]]; then |
| 289 | + BASE="${FILE%.zip}" |
| 290 | + # Replace underscores with hyphens and add version |
| 291 | + NEW_NAME=$(echo "$BASE" | sed 's/_/-/g')-"$VERSION".zip |
| 292 | + mv "$FILE" "$NEW_NAME" |
| 293 | + fi |
| 294 | + done |
| 295 | +
|
| 296 | + - name: Generate SHA256 hashes for each file |
| 297 | + run: | |
| 298 | + cd dist |
| 299 | +
|
| 300 | + # For each file in dist, generate its SHA256 hash and create a .sha256 file |
| 301 | + for FILE in *; do |
| 302 | + if [[ -f "$FILE" ]]; then |
| 303 | + # Generate SHA256 hash and save it to a .sha256 file |
| 304 | + sha256sum "$FILE" | awk '{print $1}' > "$FILE.sha256" |
| 305 | + fi |
| 306 | + done |
| 307 | +
|
| 308 | + - name: List files in dist |
| 309 | + run: ls -R dist |
| 310 | + |
| 311 | + - name: Download body.md artifact |
| 312 | + uses: actions/download-artifact@v4 |
| 313 | + with: |
| 314 | + name: body.md |
| 315 | + |
| 316 | + - name: Release |
| 317 | + uses: softprops/action-gh-release@v2 |
| 318 | + with: |
| 319 | + body_path: "body.md" |
| 320 | + tag_name: ${{ steps.extract_version.outputs.version }} |
| 321 | + files: | |
| 322 | + dist/*.zip |
| 323 | + dist/*.whl |
| 324 | + dist/*.tar.gz |
| 325 | + dist/*.sha256 |
| 326 | + prerelease: true |
| 327 | + env: |
| 328 | + GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
0 commit comments