forked from 1b-agent/opencadstudio-upstream
Run multiline workflow steps inside Nix
Co-authored-by: dichhead <330471626+dichhead@users.noreply.github.com>
This commit is contained in:
1 parent
9b273102ac
commit
342c02d77c
3 files changed
+51
-18
No files matched your search
+30
-11
@@ -77,7 +77,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
RELEASE_TAG: ${{ steps.source.outputs.tag }}
|
RELEASE_TAG: ${{ steps.source.outputs.tag }}
|
||||||
run: |
|
run: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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"
|
||||||
@@ -86,6 +86,8 @@ jobs:
|
|||||||
test "v$VERSION" = "$RELEASE_TAG"
|
test "v$VERSION" = "$RELEASE_TAG"
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Build web bundle
|
- 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
|
run: nix develop --command trunk build --locked --release --public-url /app/ --dist dist/app --html-output index.html web-app.html
|
||||||
@@ -97,26 +99,37 @@ jobs:
|
|||||||
path: website
|
path: website
|
||||||
|
|
||||||
- name: Validate website
|
- name: Validate website
|
||||||
working-directory: website
|
run: nix develop "$GITHUB_WORKSPACE/website" --command python3 "$GITHUB_WORKSPACE/website/scripts/test_site.py"
|
||||||
run: nix develop --command python3 scripts/test_site.py
|
|
||||||
|
|
||||||
- name: Assemble landing page
|
- name: Assemble landing page
|
||||||
working-directory: website
|
run: |
|
||||||
run: nix develop --command sh scripts/assemble-site.sh "$GITHUB_WORKSPACE/dist"
|
SCRIPT=$(cat <<'EOF'
|
||||||
|
cd "$GITHUB_WORKSPACE/website"
|
||||||
|
sh "$GITHUB_WORKSPACE/website/scripts/assemble-site.sh" "$GITHUB_WORKSPACE/dist"
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop "$GITHUB_WORKSPACE/website" --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Record website source
|
- name: Record website source
|
||||||
working-directory: website
|
run: |
|
||||||
run: nix develop --command bash --noprofile --norc -euo pipefail -c 'git rev-parse HEAD > "$GITHUB_WORKSPACE/dist/site-version.txt"'
|
SCRIPT=$(cat <<'EOF'
|
||||||
|
cd "$GITHUB_WORKSPACE/website"
|
||||||
|
git rev-parse HEAD > "$GITHUB_WORKSPACE/dist/site-version.txt"
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
nix develop "$GITHUB_WORKSPACE/website" --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: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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
|
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.
|
||||||
@@ -130,7 +143,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
OCS_PATREON_TOKEN: ${{ secrets.OCS_PATREON_TOKEN }}
|
OCS_PATREON_TOKEN: ${{ secrets.OCS_PATREON_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
SCRIPT=$(cat <<'EOF'
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
@@ -241,6 +254,8 @@ jobs:
|
|||||||
print(f"supporters: {len(supporters)}")
|
print(f"supporters: {len(supporters)}")
|
||||||
PY
|
PY
|
||||||
EOF
|
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
|
||||||
@@ -254,7 +269,7 @@ jobs:
|
|||||||
# unavailable during deployment.
|
# unavailable during deployment.
|
||||||
- name: Generate videos.json
|
- name: Generate videos.json
|
||||||
run: |
|
run: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
SCRIPT=$(cat <<'EOF'
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
@@ -313,13 +328,15 @@ 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
|
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: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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) {
|
||||||
@@ -365,6 +382,8 @@ 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
|
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:
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Prepare AppDir
|
- name: Prepare AppDir
|
||||||
run: |
|
run: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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
|
||||||
@@ -68,6 +68,8 @@ jobs:
|
|||||||
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
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Pack shared Linux payload
|
- name: Pack shared Linux payload
|
||||||
run: nix develop --command tar -C AppDir -czf linux-payload.tar.gz usr
|
run: nix develop --command tar -C AppDir -czf linux-payload.tar.gz usr
|
||||||
@@ -82,16 +84,18 @@ jobs:
|
|||||||
|
|
||||||
- name: Download linuxdeploy
|
- name: Download linuxdeploy
|
||||||
run: |
|
run: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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
|
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: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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 \
|
||||||
@@ -99,17 +103,21 @@ jobs:
|
|||||||
--output appimage
|
--output appimage
|
||||||
mv Open*CAD*Studio*.AppImage OpenCADStudio.AppImage
|
mv Open*CAD*Studio*.AppImage OpenCADStudio.AppImage
|
||||||
EOF
|
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: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
build-snap:
|
build-snap:
|
||||||
needs: build-appimage
|
needs: build-appimage
|
||||||
@@ -149,12 +157,14 @@ jobs:
|
|||||||
- name: Set package version
|
- name: Set package version
|
||||||
id: package
|
id: package
|
||||||
run: |
|
run: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
SCRIPT=$(cat <<'EOF'
|
||||||
VERSION=$(python3 scripts/release.py versions --tag "$RELEASE_TAG" | sed -n 's/^version=//p')
|
VERSION=$(python3 scripts/release.py versions --tag "$RELEASE_TAG" | sed -n 's/^version=//p')
|
||||||
test -n "$VERSION"
|
test -n "$VERSION"
|
||||||
sed -i "s/^version: .*/version: '$VERSION'/" snap/snapcraft.yaml
|
sed -i "s/^version: .*/version: '$VERSION'/" snap/snapcraft.yaml
|
||||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
EOF
|
EOF
|
||||||
|
)
|
||||||
|
nix develop --command bash --noprofile --norc -euo pipefail -c "$SCRIPT"
|
||||||
|
|
||||||
- name: Build snap
|
- name: Build snap
|
||||||
id: snapcraft
|
id: snapcraft
|
||||||
@@ -169,11 +179,13 @@ jobs:
|
|||||||
SNAP: ${{ steps.snapcraft.outputs.snap }}
|
SNAP: ${{ steps.snapcraft.outputs.snap }}
|
||||||
VERSION: ${{ steps.package.outputs.version }}
|
VERSION: ${{ steps.package.outputs.version }}
|
||||||
run: |
|
run: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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
|
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 != ''
|
||||||
|
|||||||
@@ -43,13 +43,15 @@ jobs:
|
|||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
PUBLISH: ${{ github.event_name == 'schedule' || inputs.publish }}
|
PUBLISH: ${{ github.event_name == 'schedule' || inputs.publish }}
|
||||||
run: |
|
run: |
|
||||||
nix develop --command bash --noprofile --norc -euo pipefail <<'EOF'
|
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
|
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:
|
||||||
|
|||||||
Reference in new issue
Block a user