Skip to content

Commit

Permalink
ci: enables semantic release on console
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdmike committed May 1, 2024
1 parent 74a7d64 commit ca9ed3e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 15 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ jobs:
with:
repository: open-amt-cloud-toolkit/sample-web-ui
ref: enterprise #TODO: pull latest tagged version
path: ./ui
path: ./temp
- run: npm ci
working-directory: ./temp
- run: npm run build-enterprise
- name: Use Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "20.x"
working-directory: ./temp
- name: move files
run: mv ./temp/ui/* ./internal/controller/http/v1/ui
- name: Docker Login
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ bin/

# Dependency directories (remove the comment below to include it)
vendor/
ui/
# ...ignore the ui folder
**/ui/*
# ...but keep the folder
!**/ui/.gitkeep
2 changes: 1 addition & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[
"@semantic-release/exec",
{
"prepareCmd": "docker build -t vprodemo.azurecr.io/console:v${nextRelease.version} . && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \"-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=${nextRelease.version}'\" -trimpath -o console_linux_x64 ./cmd/main.go && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags \"-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=${nextRelease.version}'\" -trimpath -o console_windows_x64.exe ./cmd/main.go",
"prepareCmd": "docker build -t vprodemo.azurecr.io/console:v${nextRelease.version} . && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags \"-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=${nextRelease.version}'\" -trimpath -o console_linux_x64 ./cmd/app/main.go && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags \"-s -w -X 'github.com/open-amt-cloud-toolkit/console/internal/app.Version=${nextRelease.version}'\" -trimpath -o console_windows_x64.exe ./cmd/app/main.go",
"publishCmd": "docker push vprodemo.azurecr.io/console:v${nextRelease.version}",
"verifyReleaseCmd": "echo v${nextRelease.version} > .nextVersion"
}
Expand Down
31 changes: 23 additions & 8 deletions internal/controller/http/v1/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
package v1

import (
"embed"
"io/fs"
"log"
"net/http"

"github.com/gin-gonic/gin"
Expand All @@ -13,6 +16,9 @@ import (
"github.com/open-amt-cloud-toolkit/console/pkg/logger"
)

//go:embed all:ui
var content embed.FS

// NewRouter -.
// Swagger spec:
// @title Console API for Device Management Toolkit
Expand All @@ -26,13 +32,22 @@ func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases) {
handler.Use(gin.Recovery())
// Static files
// Serve static assets (js, css, images, etc.)
handler.StaticFile("/", "./ui/index.html")
handler.StaticFile("/main.js", "./ui/main.js")
handler.StaticFile("/polyfills.js", "./ui/polyfills.js")
handler.StaticFile("/runtime.js", "./ui/runtime.js")
handler.StaticFile("/styles.css", "./ui/styles.css")
handler.StaticFile("/vendor.js", "./ui/vendor.js")
handler.StaticFile("/favicon.ico", "./ui/favicon.ico")
// Create subdirectory view of the embedded file system
staticFiles, err := fs.Sub(content, "ui")
if err != nil {
log.Fatal(err)
}

// Set up HTTP server to handle requests
handler.StaticFileFS("/", "./", http.FS(staticFiles)) // Serve static files from "/" route
handler.StaticFileFS("/main.js", "./main.js", http.FS(staticFiles))
handler.StaticFileFS("/polyfills.js", "./polyfills.js", http.FS(staticFiles))
handler.StaticFileFS("/runtime.js", "./runtime.js", http.FS(staticFiles))
handler.StaticFileFS("/styles.css", "./styles.css", http.FS(staticFiles))
handler.StaticFileFS("/vendor.js", "./vendor.js", http.FS(staticFiles))
handler.StaticFileFS("/favicon.ico", "./favicon.ico", http.FS(staticFiles))
handler.StaticFileFS("/assets/logo.png", "./assets/logo.png", http.FS(staticFiles))

// Swagger
swaggerHandler := ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "DISABLE_SWAGGER_HTTP_HANDLER")
handler.GET("/swagger/*any", swaggerHandler)
Expand Down Expand Up @@ -61,6 +76,6 @@ func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases) {

// Catch-all route to serve index.html for any route not matched above to be handled by Angular
handler.NoRoute(func(c *gin.Context) {
c.File("./ui/index.html")
c.FileFromFS("./", http.FS(staticFiles)) // Serve static files from "/" route
})
}
Empty file.

0 comments on commit ca9ed3e

Please sign in to comment.