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 f2090df
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 48 deletions.
72 changes: 36 additions & 36 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,52 @@ name: Semantic-Release CI

on:
push:
branches: [ main ]
branches: [main]

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit

- name: Checkout Console
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
- name: Checkout Console
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
with:
persist-credentials: false
- name: Check out Sample Web UI
uses: actions/checkout@master
with:
- name: Check out Sample Web UI
uses: actions/checkout@master
with:
repository: open-amt-cloud-toolkit/sample-web-ui
ref: enterprise #TODO: pull latest tagged version
path: ./ui
- run: npm ci
- run: npm run build-enterprise
- name: Use Node.js 20.x
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: "20.x"
- name: Docker Login
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0
with:
registry: vprodemo.azurecr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
logout: true
- name: Semantic Release
uses: cycjimmy/semantic-release-action@cb425203a562475bca039ba4dbf90c7f9ac790f4 # v4.1.0
with:
semantic_version: 19.0.5 # It is recommended to specify a version range
# for semantic-release when using
# semantic-release-action lower than @v3
extra_plugins: |
@semantic-release/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.ROSIE_TOKEN }}

path: ./temp
- run: npm ci
working-directory: ./temp
- run: npm run build-enterprise
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:
registry: vprodemo.azurecr.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
logout: true
- name: Semantic Release
uses: cycjimmy/semantic-release-action@cb425203a562475bca039ba4dbf90c7f9ac790f4 # v4.1.0
with:
semantic_version:
19.0.5 # It is recommended to specify a version range
# for semantic-release when using
# semantic-release-action lower than @v3
extra_plugins: |
@semantic-release/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.ROSIE_TOKEN }}

# - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
# if: ${{ steps.version.outputs.next != 'none' }}
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
5 changes: 2 additions & 3 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
[
"@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"
}
],
"@semantic-release/git"
]
]
}
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 f2090df

Please sign in to comment.