forked from 1b-agent/opencadstudio-upstream
Merge pull request #4 from dichhead/copilot/overhaul-ci-nix
Overhaul CI around the repository flake and move Linux/web automation to Nix
This commit is contained in:
7 files changed
+205
-59
No files matched your search
@@ -0,0 +1,14 @@
|
|||||||
|
name: Setup Nix
|
||||||
|
description: Install Nix and enable the shared binary cache for flake-based CI jobs
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Install Nix
|
||||||
|
uses: DeterminateSystems/nix-installer-action@v23
|
||||||
|
with:
|
||||||
|
extra-conf: |
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
|
||||||
|
- name: Enable Magic Nix Cache
|
||||||
|
uses: DeterminateSystems/magic-nix-cache-action@v15
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ci-${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
flake:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
|
- name: Run flake checks
|
||||||
|
run: nix flake check --print-build-logs
|
||||||
|
|
||||||
|
rust:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
|
- name: Check formatting
|
||||||
|
run: nix develop --command cargo fmt --all --check
|
||||||
|
- name: Run clippy
|
||||||
|
run: nix develop --command cargo clippy --locked --workspace --all-targets -- -D warnings
|
||||||
|
- name: Run workspace tests
|
||||||
|
run: nix develop --command cargo test --locked --workspace
|
||||||
|
|
||||||
|
web:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
|
- name: Verify wasm target
|
||||||
|
run: nix develop --command rustc --print target-libdir --target wasm32-unknown-unknown > /dev/null
|
||||||
|
- name: Build web bundle
|
||||||
|
run: nix develop --command trunk build --locked --release --public-url /app/ --dist dist/app --html-output index.html web-app.html
|
||||||
|
- name: Validate website assembly
|
||||||
|
run: nix develop --command python3 scripts/test_site.py
|
||||||
|
|
||||||
|
release-automation:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
|
- name: Test release automation
|
||||||
|
run: nix develop --command python3 scripts/test_release.py
|
||||||
+50
-33
@@ -39,6 +39,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Resolve release source
|
- name: Resolve release source
|
||||||
id: source
|
id: source
|
||||||
|
shell: bash
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
RELEASE_TAG: ${{ inputs.tag || github.event.release.tag_name }}
|
RELEASE_TAG: ${{ inputs.tag || github.event.release.tag_name }}
|
||||||
@@ -70,10 +71,13 @@ jobs:
|
|||||||
# release tag; a shallow clone would label the build `+g<hash>`.
|
# release tag; a shallow clone would label the build `+g<hash>`.
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
|
|
||||||
- name: Validate release version
|
- name: Validate release version
|
||||||
env:
|
env:
|
||||||
RELEASE_TAG: ${{ steps.source.outputs.tag }}
|
RELEASE_TAG: ${{ steps.source.outputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
git merge-base --is-ancestor "$RELEASE_TAG" HEAD
|
git merge-base --is-ancestor "$RELEASE_TAG" HEAD
|
||||||
if [ -f scripts/release.py ]; then
|
if [ -f scripts/release.py ]; then
|
||||||
python3 scripts/release.py versions --tag "$RELEASE_TAG"
|
python3 scripts/release.py versions --tag "$RELEASE_TAG"
|
||||||
@@ -81,63 +85,64 @@ jobs:
|
|||||||
VERSION=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1)
|
VERSION=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -1)
|
||||||
test "v$VERSION" = "$RELEASE_TAG"
|
test "v$VERSION" = "$RELEASE_TAG"
|
||||||
fi
|
fi
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- uses: dtolnay/rust-toolchain@stable
|
- name: Verify wasm target
|
||||||
with:
|
run: nix develop --command rustc --print target-libdir --target wasm32-unknown-unknown > /dev/null
|
||||||
targets: wasm32-unknown-unknown
|
|
||||||
|
|
||||||
- uses: Swatinem/rust-cache@v2
|
|
||||||
|
|
||||||
- name: Install trunk
|
|
||||||
uses: taiki-e/install-action@v2
|
|
||||||
with:
|
|
||||||
tool: trunk
|
|
||||||
|
|
||||||
- name: Read wasm-bindgen version
|
|
||||||
id: wasm-bindgen-version
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
VERSION=$(sed -n '/name = "wasm-bindgen"/{n;s/version = "\(.*\)"/\1/p;q;}' Cargo.lock)
|
|
||||||
test -n "$VERSION"
|
|
||||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Install wasm-bindgen CLI
|
|
||||||
uses: taiki-e/install-action@v2
|
|
||||||
with:
|
|
||||||
tool: wasm-bindgen@${{ steps.wasm-bindgen-version.outputs.version }}
|
|
||||||
|
|
||||||
- name: Build web bundle
|
- name: Build web bundle
|
||||||
run: trunk build --locked --release --public-url /app/ --dist dist/app --html-output index.html web-app.html
|
run: nix develop --command trunk build --locked --release --public-url /app/ --dist dist/app --html-output index.html web-app.html
|
||||||
|
|
||||||
- name: Check out current website
|
- name: Check out current website
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
path: website
|
path: website-source
|
||||||
|
|
||||||
- name: Validate website
|
- name: Validate website
|
||||||
working-directory: website
|
run: |
|
||||||
run: python3 scripts/test_site.py
|
SCRIPT=$(cat <<'EOF'
|
||||||
|
cd "$GITHUB_WORKSPACE/website-source"
|
||||||
|
python3 scripts/test_site.py
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Assemble landing page
|
- name: Assemble landing page
|
||||||
working-directory: website
|
run: |
|
||||||
run: sh scripts/assemble-site.sh "$GITHUB_WORKSPACE/dist"
|
SCRIPT=$(cat <<'EOF'
|
||||||
|
cd "$GITHUB_WORKSPACE/website-source"
|
||||||
|
sh "$GITHUB_WORKSPACE/website-source/scripts/assemble-site.sh" "$GITHUB_WORKSPACE/dist"
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Record website source
|
- name: Record website source
|
||||||
working-directory: website
|
run: |
|
||||||
run: git rev-parse HEAD > "$GITHUB_WORKSPACE/dist/site-version.txt"
|
SCRIPT=$(cat <<'EOF'
|
||||||
|
cd "$GITHUB_WORKSPACE/website-source"
|
||||||
|
git rev-parse HEAD > "$GITHUB_WORKSPACE/dist/site-version.txt"
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Record release version and source
|
- name: Record release version and source
|
||||||
env:
|
env:
|
||||||
RELEASE_TAG: ${{ steps.source.outputs.tag }}
|
RELEASE_TAG: ${{ steps.source.outputs.tag }}
|
||||||
RELEASE_COMMIT: ${{ steps.source.outputs.commit }}
|
RELEASE_COMMIT: ${{ steps.source.outputs.commit }}
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
jq -n --arg version "${RELEASE_TAG#v}" --arg commit "$RELEASE_COMMIT" \
|
jq -n --arg version "${RELEASE_TAG#v}" --arg commit "$RELEASE_COMMIT" \
|
||||||
'{version: $version, commit: $commit}' > dist/app/release.json
|
'{version: $version, commit: $commit}' > dist/app/release.json
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
# GitHub Pages runs Jekyll, which ignores files; opt out so the
|
# GitHub Pages runs Jekyll, which ignores files; opt out so the
|
||||||
# wasm-bindgen output is served verbatim.
|
# wasm-bindgen output is served verbatim.
|
||||||
- run: touch dist/.nojekyll
|
- run: nix develop --command touch dist/.nojekyll
|
||||||
|
|
||||||
# The web app can't call the Patreon API directly (CORS + the token would
|
# The web app can't call the Patreon API directly (CORS + the token would
|
||||||
# be exposed in the bundle), so generate the supporters list server-side
|
# be exposed in the bundle), so generate the supporters list server-side
|
||||||
@@ -147,6 +152,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
OCS_PATREON_TOKEN: ${{ secrets.OCS_PATREON_TOKEN }}
|
OCS_PATREON_TOKEN: ${{ secrets.OCS_PATREON_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@@ -256,12 +262,15 @@ jobs:
|
|||||||
)
|
)
|
||||||
print(f"supporters: {len(supporters)}")
|
print(f"supporters: {len(supporters)}")
|
||||||
PY
|
PY
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
# Publish separate light/dark charts for stars and release downloads.
|
# Publish separate light/dark charts for stars and release downloads.
|
||||||
- name: Generate project growth charts
|
- name: Generate project growth charts
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.OCS_GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.OCS_GITHUB_TOKEN }}
|
||||||
run: python3 website/scripts/generate-star-history.py --output-dir dist
|
run: nix develop --command python3 website-source/scripts/generate-star-history.py --output-dir dist
|
||||||
|
|
||||||
# Browsers cannot reliably fetch YouTube playlist/oEmbed responses because
|
# Browsers cannot reliably fetch YouTube playlist/oEmbed responses because
|
||||||
# of CORS. Build a same-origin listing and thumbnail directory for the
|
# of CORS. Build a same-origin listing and thumbnail directory for the
|
||||||
@@ -269,6 +278,7 @@ jobs:
|
|||||||
# unavailable during deployment.
|
# unavailable during deployment.
|
||||||
- name: Generate videos.json
|
- name: Generate videos.json
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
@@ -326,12 +336,16 @@ jobs:
|
|||||||
|
|
||||||
print(f"videos: {len(json.loads(output.read_text(encoding='utf-8')))}")
|
print(f"videos: {len(json.loads(output.read_text(encoding='utf-8')))}")
|
||||||
PY
|
PY
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
# Publish a public snapshot of GitHub discussions.
|
# Publish a public snapshot of GitHub discussions.
|
||||||
- name: Generate discussions.json
|
- name: Generate discussions.json
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
QUERY='
|
QUERY='
|
||||||
query($owner: String!, $name: String!) {
|
query($owner: String!, $name: String!) {
|
||||||
repository(owner: $owner, name: $name) {
|
repository(owner: $owner, name: $name) {
|
||||||
@@ -376,6 +390,9 @@ jobs:
|
|||||||
})' \
|
})' \
|
||||||
> dist/app/discussions.json
|
> dist/app/discussions.json
|
||||||
echo "discussions: $(jq 'length' dist/app/discussions.json)"
|
echo "discussions: $(jq 'length' dist/app/discussions.json)"
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- uses: actions/upload-pages-artifact@v3
|
- uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -43,29 +43,21 @@ jobs:
|
|||||||
# release tag; a shallow clone would label the build `+g<hash>`.
|
# release tag; a shallow clone would label the build `+g<hash>`.
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
|
|
||||||
- name: Validate package versions
|
- name: Validate package versions
|
||||||
id: version
|
id: version
|
||||||
shell: bash
|
shell: bash
|
||||||
run: python3 scripts/release.py versions --tag "$RELEASE_TAG"
|
run: nix develop --command python3 scripts/release.py versions --tag "$RELEASE_TAG"
|
||||||
|
|
||||||
- name: Install Rust
|
|
||||||
uses: dtolnay/rust-toolchain@stable
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -q
|
|
||||||
sudo apt-get install -y \
|
|
||||||
libgl1-mesa-dev libx11-dev libxcursor-dev libxi-dev libxrandr-dev \
|
|
||||||
libxkbcommon-dev libwayland-dev libfontconfig1-dev libfreetype6-dev \
|
|
||||||
librsvg2-bin fuse libfuse2
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
OCS_PATREON_TOKEN: ${{ secrets.OCS_PATREON_TOKEN }}
|
OCS_PATREON_TOKEN: ${{ secrets.OCS_PATREON_TOKEN }}
|
||||||
run: cargo build --locked --release
|
run: nix develop --command cargo build --locked --release
|
||||||
|
|
||||||
- name: Prepare AppDir
|
- name: Prepare AppDir
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
mkdir -p AppDir/usr/bin
|
mkdir -p AppDir/usr/bin
|
||||||
mkdir -p AppDir/usr/share/applications
|
mkdir -p AppDir/usr/share/applications
|
||||||
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
|
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
|
||||||
@@ -75,9 +67,12 @@ jobs:
|
|||||||
cp packaging/io.github.HakanSeven12.OpenCadStudio.metainfo.xml AppDir/usr/share/metainfo/
|
cp packaging/io.github.HakanSeven12.OpenCadStudio.metainfo.xml AppDir/usr/share/metainfo/
|
||||||
rsvg-convert -w 256 -h 256 assets/logo.svg \
|
rsvg-convert -w 256 -h 256 assets/logo.svg \
|
||||||
-o AppDir/usr/share/icons/hicolor/256x256/apps/io.github.HakanSeven12.OpenCadStudio.png
|
-o AppDir/usr/share/icons/hicolor/256x256/apps/io.github.HakanSeven12.OpenCadStudio.png
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Pack shared Linux payload
|
- name: Pack shared Linux payload
|
||||||
run: tar -C AppDir -czf linux-payload.tar.gz usr
|
run: nix develop --command tar -C AppDir -czf linux-payload.tar.gz usr
|
||||||
|
|
||||||
- name: Upload shared Linux payload
|
- name: Upload shared Linux payload
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
@@ -89,28 +84,40 @@ jobs:
|
|||||||
|
|
||||||
- name: Download linuxdeploy
|
- name: Download linuxdeploy
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
|
wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
|
||||||
chmod +x linuxdeploy-x86_64.AppImage
|
chmod +x linuxdeploy-x86_64.AppImage
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Build AppImage
|
- name: Build AppImage
|
||||||
env:
|
env:
|
||||||
APPIMAGE_EXTRACT_AND_RUN: 1
|
APPIMAGE_EXTRACT_AND_RUN: 1
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
./linuxdeploy-x86_64.AppImage \
|
./linuxdeploy-x86_64.AppImage \
|
||||||
--appdir AppDir \
|
--appdir AppDir \
|
||||||
--desktop-file AppDir/usr/share/applications/io.github.HakanSeven12.OpenCadStudio.desktop \
|
--desktop-file AppDir/usr/share/applications/io.github.HakanSeven12.OpenCadStudio.desktop \
|
||||||
--icon-file AppDir/usr/share/icons/hicolor/256x256/apps/io.github.HakanSeven12.OpenCadStudio.png \
|
--icon-file AppDir/usr/share/icons/hicolor/256x256/apps/io.github.HakanSeven12.OpenCadStudio.png \
|
||||||
--output appimage
|
--output appimage
|
||||||
mv Open*CAD*Studio*.AppImage OpenCADStudio.AppImage
|
mv Open*CAD*Studio*.AppImage OpenCADStudio.AppImage
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Upload AppImage to release
|
- name: Upload AppImage to release
|
||||||
if: env.RELEASE_TAG != ''
|
if: env.RELEASE_TAG != ''
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
ASSET=OpenCADStudio-${{ env.RELEASE_TAG }}-linux-x86_64.AppImage
|
ASSET=OpenCADStudio-${{ env.RELEASE_TAG }}-linux-x86_64.AppImage
|
||||||
mv OpenCADStudio.AppImage "$ASSET"
|
mv OpenCADStudio.AppImage "$ASSET"
|
||||||
gh release upload ${{ env.RELEASE_TAG }} "$ASSET" --clobber --repo ${{ github.repository }}
|
gh release upload ${{ env.RELEASE_TAG }} "$ASSET" --clobber --repo ${{ github.repository }}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
build-snap:
|
build-snap:
|
||||||
needs: build-appimage
|
needs: build-appimage
|
||||||
@@ -134,10 +141,12 @@ jobs:
|
|||||||
# release tag; a shallow clone would label the build `+g<hash>`.
|
# release tag; a shallow clone would label the build `+g<hash>`.
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
|
|
||||||
- name: Validate package versions
|
- name: Validate package versions
|
||||||
id: version
|
id: version
|
||||||
shell: bash
|
shell: bash
|
||||||
run: python3 scripts/release.py versions --tag "$RELEASE_TAG"
|
run: nix develop --command python3 scripts/release.py versions --tag "$RELEASE_TAG"
|
||||||
|
|
||||||
- name: Download shared Linux payload
|
- name: Download shared Linux payload
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
@@ -145,48 +154,68 @@ jobs:
|
|||||||
name: linux-payload
|
name: linux-payload
|
||||||
path: .
|
path: .
|
||||||
|
|
||||||
- name: Set package version
|
- name: Prepare snap project
|
||||||
id: package
|
id: package
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ steps.version.outputs.version }}
|
VERSION: ${{ steps.version.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
sed -i "s/^version: .*/version: '$VERSION'/" snap/snapcraft.yaml
|
SCRIPT=$(cat <<'EOF'
|
||||||
|
test -n "$VERSION"
|
||||||
|
rm -rf .snap-build
|
||||||
|
mkdir -p .snap-build
|
||||||
|
shopt -s dotglob
|
||||||
|
for entry in * .*; do
|
||||||
|
case "$entry" in
|
||||||
|
.|..|.git|.snap-build) continue ;;
|
||||||
|
esac
|
||||||
|
cp -a "$entry" .snap-build/
|
||||||
|
done
|
||||||
|
sed -i "s/^version: .*/version: '$VERSION'/" .snap-build/snap/snapcraft.yaml
|
||||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Build snap
|
- name: Build snap
|
||||||
id: snapcraft
|
id: snapcraft
|
||||||
uses: snapcore/action-build@v1
|
uses: snapcore/action-build@v1
|
||||||
|
with:
|
||||||
|
path: .snap-build
|
||||||
|
|
||||||
- name: Normalize snap package name
|
- name: Normalize snap package name
|
||||||
id: snap_package
|
id: snap_asset
|
||||||
env:
|
env:
|
||||||
SNAP: ${{ steps.snapcraft.outputs.snap }}
|
SNAP: ${{ steps.snapcraft.outputs.snap }}
|
||||||
VERSION: ${{ steps.package.outputs.version }}
|
VERSION: ${{ steps.package.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
PACKAGE="OpenCADStudio-v${VERSION}-linux-x86_64.snap"
|
PACKAGE="OpenCADStudio-v${VERSION}-linux-x86_64.snap"
|
||||||
mv "$SNAP" "$PACKAGE"
|
mv "$SNAP" "$PACKAGE"
|
||||||
echo "snap=$PACKAGE" >> "$GITHUB_OUTPUT"
|
echo "snap=$PACKAGE" >> "$GITHUB_OUTPUT"
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Upload snap to release
|
- name: Upload snap to release
|
||||||
if: env.RELEASE_TAG != ''
|
if: env.RELEASE_TAG != ''
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
SNAP: ${{ steps.snap_package.outputs.snap }}
|
SNAP: ${{ steps.snap_asset.outputs.snap }}
|
||||||
run: gh release upload "${{ env.RELEASE_TAG }}" "$SNAP" --clobber
|
run: nix develop --command gh release upload "${{ env.RELEASE_TAG }}" "$SNAP" --clobber --repo ${{ github.repository }}
|
||||||
|
|
||||||
- name: Upload snap as workflow artifact
|
- name: Upload snap as workflow artifact
|
||||||
if: env.RELEASE_TAG == ''
|
if: env.RELEASE_TAG == ''
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: OpenCADStudio-v${{ steps.package.outputs.version }}-linux-x86_64-snap
|
name: OpenCADStudio-v${{ steps.package.outputs.version }}-linux-x86_64-snap
|
||||||
path: ${{ steps.snap_package.outputs.snap }}
|
path: ${{ steps.snap_asset.outputs.snap }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Publish snap to edge
|
- name: Publish snap to edge
|
||||||
if: env.RELEASE_TAG != '' && env.SNAPCRAFT_STORE_CREDENTIALS != ''
|
if: env.RELEASE_TAG != '' && env.SNAPCRAFT_STORE_CREDENTIALS != ''
|
||||||
uses: snapcore/action-publish@v1
|
uses: snapcore/action-publish@v1
|
||||||
with:
|
with:
|
||||||
snap: ${{ steps.snap_package.outputs.snap }}
|
snap: ${{ steps.snap_asset.outputs.snap }}
|
||||||
release: edge
|
release: edge
|
||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
@@ -546,7 +575,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ inputs.commit || github.sha }}
|
ref: ${{ inputs.commit || github.sha }}
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
- name: Verify native release assets and notes
|
- name: Verify native release assets and notes
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
run: python3 scripts/release.py verify-native --tag "$RELEASE_TAG"
|
run: nix develop --command python3 scripts/release.py verify-native --tag "$RELEASE_TAG"
|
||||||
@@ -34,19 +34,24 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
- uses: ./.github/actions/setup-nix
|
||||||
- name: Validate release automation
|
- name: Validate release automation
|
||||||
run: python3 scripts/test_release.py
|
run: nix develop --command python3 scripts/test_release.py
|
||||||
- name: Prepare release and verify published notes
|
- name: Prepare release and verify published notes
|
||||||
id: release
|
id: release
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
PUBLISH: ${{ github.event_name == 'schedule' || inputs.publish }}
|
PUBLISH: ${{ github.event_name == 'schedule' || inputs.publish }}
|
||||||
run: |
|
run: |
|
||||||
|
SCRIPT=$(cat <<'EOF'
|
||||||
if [ "$PUBLISH" = true ]; then
|
if [ "$PUBLISH" = true ]; then
|
||||||
python3 scripts/release.py prepare --publish
|
python3 scripts/release.py prepare --publish
|
||||||
else
|
else
|
||||||
python3 scripts/release.py prepare
|
python3 scripts/release.py prepare
|
||||||
fi
|
fi
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
# GITHUB_TOKEN releases do not trigger release events, so call both builds.
|
# GITHUB_TOKEN releases do not trigger release events, so call both builds.
|
||||||
web:
|
web:
|
||||||
|
|||||||
@@ -131,6 +131,26 @@ Change the language from the application settings. The browser version also uses
|
|||||||
|
|
||||||
## Build from source
|
## Build from source
|
||||||
|
|
||||||
|
### Nix
|
||||||
|
|
||||||
|
The GitHub workflows use the repository flake for a reproducible Rust, web, and automation toolchain. To match CI locally:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/HakanSeven12/OpenCADStudio.git
|
||||||
|
cd OpenCADStudio
|
||||||
|
nix develop
|
||||||
|
```
|
||||||
|
|
||||||
|
From that shell, run the same commands CI does, for example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cargo fmt --all --check
|
||||||
|
cargo test --locked --workspace
|
||||||
|
trunk build --locked --release --public-url /app/ --dist dist/app --html-output index.html web-app.html
|
||||||
|
python3 scripts/test_site.py
|
||||||
|
python3 scripts/test_release.py
|
||||||
|
```
|
||||||
|
|
||||||
### Desktop
|
### Desktop
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
|
|||||||
@@ -132,9 +132,15 @@
|
|||||||
fontconfig
|
fontconfig
|
||||||
freetype
|
freetype
|
||||||
git
|
git
|
||||||
|
python3
|
||||||
|
nodejs
|
||||||
|
gh
|
||||||
|
jq
|
||||||
|
wget
|
||||||
|
# CI and local automation scripts rely on these CLIs so GitHub
|
||||||
|
# Actions and contributors can share the same flake-defined env.
|
||||||
# Web build: `trunk build` per Trunk.toml. wasm-bindgen-cli must
|
# Web build: `trunk build` per Trunk.toml. wasm-bindgen-cli must
|
||||||
# match the wasm-bindgen version Cargo.lock resolves, the same
|
# match the wasm-bindgen version Cargo.lock resolves.
|
||||||
# constraint .github/workflows/pages.yml:83 reads out of the lock.
|
|
||||||
trunk
|
trunk
|
||||||
wasm-bindgen-cli
|
wasm-bindgen-cli
|
||||||
# Rasterises assets/logo.svg for packaging, as release.yml does.
|
# Rasterises assets/logo.svg for packaging, as release.yml does.
|
||||||
|
|||||||
Reference in new issue
Block a user