Skip to content

Commit

Permalink
Improve packaging and website publication (#275)
Browse files Browse the repository at this point in the history
* publish website after release publication

* update boxzer

* run all builds even on failure

* update package test

* update github actions

* add dependency to package test
  • Loading branch information
mattnite authored Nov 7, 2024
1 parent 16dc205 commit 3968888
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
jobs:
build:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
os: [
Expand Down Expand Up @@ -47,7 +48,7 @@ jobs:
sleep 1
cd tools/package-test
zig fetch --save=microzig http://localhost:8000/microzig-${MICROZIG_VERSION}.tar.gz
zig fetch --save=microzig/port/raspberrypi/rp2xxx http://localhost:8000/${MICROZIG_VERSION}/port/raspberrypi/rp2xxx.tar.gz
zig build -Doptimize=ReleaseSmall
zig build run-port-tests
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,23 @@ jobs:
- name: Assemble Packages
run: zig build package -- "${{ secrets.DOWNLOADS_URL }}"

- name: Deploy
uses: easingthemes/ssh-deploy@main
with:
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_PRIVATE_KEY }}
ARGS: "-vzrli"
SOURCE: "boxzer-out/"
REMOTE_HOST: ${{ secrets.DEPLOY_HOST }}
REMOTE_USER: ${{ secrets.DEPLOY_USER }}
REMOTE_PORT: ${{ secrets.DEPLOY_PORT }}
TARGET: "."

- name: Create Release Draft
uses: ncipollo/release-action@v1
id: create_release
with:
tag: ${{ env.TAG_NAME }}
artifactErrorsFailBuild: true
draft: true
generateReleaseNotes: true

- name: Create Tarball
run: |
tar -czvf boxzer-out.tar.gz -C boxzer-out .
- name: Upload Artifact to Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: boxzer-out.tar.gz
asset_name: boxzer-out.tar.gz
asset_content_type: application/gzip
45 changes: 45 additions & 0 deletions .github/workflows/publish-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
workflow_dispatch:
push:
branches: [main]
release:
types:
- published

jobs:
# Build job
Expand All @@ -16,10 +19,52 @@ jobs:
with:
version: 0.13.0

- name: Download and install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install -y gh
- name: Authenticate with GitHub CLI
run: gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"

- name: Build
working-directory: website
run: zig build

- name: List, download, unpack, and generate metadata
run: |
# Create an array to store releases with the artifact
releases_with_artifact=()
# Fetch all releases and iterate over them
releases=$(gh release list --limit 100 --repo ${{ github.repository }} | awk '{print $1}')
for release in $releases; do
echo "Processing release: $release"
# Create the target directory if it doesn't exist
mkdir -p zig-out/www/downloads/microzig
# Download the artifact 'boxzer-out.tar.gz' if it exists
gh release download "$release" --pattern "boxzer-out.tar.gz" --repo ${{ github.repository }} --dir .
# Check if the tarball was downloaded and unpack it
if [ -f "boxzer-out.tar.gz" ]; then
echo "Unpacking boxzer-out.tar.gz for release: $release"
tar -xzvf boxzer-out.tar.gz -C zig-out/www/downloads/microzig
rm boxzer-out.tar.gz
# Add the release to the metadata array
releases_with_artifact+=("\"$release\"")
else
echo "Artifact 'boxzer-out.tar.gz' not found for release: $release"
fi
done
# Generate metadata.json file
echo "Generating metadata.json"
echo "{ \"releases\": [$(IFS=,; echo "${releases_with_artifact[*]}")] }" > zig-out/www/downloads/microzig/metadata.json
- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
id: deployment
Expand Down
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

// used for creating package tarballs
.boxzer = .{
.url = "https://github.com/mattnite/boxzer/archive/6bd6636d780f626af1c40a27be2680e223965c8a.tar.gz",
.hash = "1220432ca3323f0a7033fd84df6d0f2d66aecf4c5301b3ac70c96cca8b0938164f17",
.url = "git+https://github.com/mattnite/boxzer#df0211603497a22c98f15a8570588e98b5aea456",
.hash = "12204528a3ad455b8281677478ef2289039f6e305f3ba049397e580cc99b439abe94",
},
},

Expand Down
15 changes: 9 additions & 6 deletions tools/package-test/build.zig
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const std = @import("std");

const ports: []const []const u8 = &.{
"microzig/port/raspberrypi/rp2xxx",
};

pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const microzig_dep = b.dependency("microzig", .{
.optimize = optimize,
});
b.getInstallStep().dependOn(microzig_dep.builder.getInstallStep());

const test_ports_step = b.step("run-port-tests", "Run all platform agnostic tests for Ports");
test_ports_step.dependOn(&microzig_dep.builder.top_level_steps.get("run-port-tests").?.step);

for (ports) |port| {
const dep = b.dependency(port, .{ .optimize = optimize });
test_ports_step.dependOn(&dep.builder.top_level_steps.get("test").?.step);
}
}

0 comments on commit 3968888

Please sign in to comment.