Skip to content

Commit

Permalink
feat: add artifacts generation templates (#2)
Browse files Browse the repository at this point in the history
* feat: add artefacts generation templates
* feat: implement feature and artefacts in github actions

Co-authored-by: Miguel Ramos <[email protected]>
miguelramos and Miguel Ramos authored Jun 9, 2022

Verified

This commit was signed with the committer’s verified signature.
macmv Neil Macneale V
1 parent 9e6b4a4 commit 35acda3
Showing 6 changed files with 90 additions and 13 deletions.
27 changes: 15 additions & 12 deletions cmd/action.go
Original file line number Diff line number Diff line change
@@ -94,18 +94,12 @@ func NewActionCmd(cmdAction *ActionCommand) *cobra.Command {
Use: "action",
Short: "Create artifacts on github actions",
Run: func(cmd *cobra.Command, args []string) {
if cmdAction.Kind == "tag" {
cmdAction.Tag(cmd)
}

if cmdAction.Kind == "branch" {
cmdAction.Branch((cmd))
}
cmdAction.ReleaseArtifact(cmd)
},
}
}

func (ctx *ActionCommand) Branch(cmd *cobra.Command) {
func (ctx *ActionCommand) ReleaseArtifact(cmd *cobra.Command) {
color.Info.Println("🥼 Starting Feature Artifacts creation")
sublime := core.GetSublime()

@@ -149,7 +143,12 @@ func (ctx *ActionCommand) Branch(cmd *cobra.Command) {

color.Info.Println("🥼 Starting creating artifact for:", pkgJson.Name)

destinationFolder := fmt.Sprintf("%s@%s-%s", pkgs[key].Name, pkgJson.Version, hash)
var destinationFolder = ""
if ctx.Kind == "branch" {
destinationFolder = fmt.Sprintf("%s@%s-%s", pkgs[key].Name, pkgJson.Version, hash)
} else {
destinationFolder = fmt.Sprintf("%s@%s", pkgs[key].Name, pkgJson.Version)
}

fileList, err := utils.PathWalk(distFolder)
if err != nil {
@@ -181,13 +180,17 @@ func (ctx *ActionCommand) Branch(cmd *cobra.Command) {
Docs: "",
})

manifestDestination := fmt.Sprintf("%s@%s-%s", pkgJson.Name, pkgJson.Version, hash)
var manifestDestination = ""
if ctx.Kind == "branch" {
manifestDestination = fmt.Sprintf("%s@%s-%s", pkgJson.Name, pkgJson.Version, hash)
} else {
manifestDestination = fmt.Sprintf("%s@%s", pkgJson.Name, pkgJson.Version)
}

supabase.Upload("manifests", manifestFile.Name(), manifestDestination)
manifestLink := fmt.Sprintf("%s/storage/v1/object/public/%s/%s/%s", ctx.BaseUrl, "manifests", manifestDestination, filepath.Base(manifestFile.Name()))
os.Remove(manifestFile.Name())

color.Info.Println("🥼 Manifest uploaded to:", manifestLink)
}
}

func (ctx *ActionCommand) Tag(cmd *cobra.Command) {}
21 changes: 21 additions & 0 deletions cmd/blueprint.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
Copyright © 2022 Websublime.dev [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package cmd

import "embed"
1 change: 0 additions & 1 deletion cmd/templates/workflow-feature.yaml
Original file line number Diff line number Diff line change
@@ -42,7 +42,6 @@ jobs:
./sublime action --kind branch --bucket "$BUCKET" --url "$STORAGE_URL" --key "$STORAGE_KEY" --env "$NODE_ENV"
# - name: Supabase artifacts
# if: contains(steps.file_changes.outputs.files , 'ws-ui-header/')
# uses: websublime/[email protected]
# with:
# url: ${{ secrets.SUPABASE_URL }}
12 changes: 12 additions & 0 deletions cmd/workspace.go
Original file line number Diff line number Diff line change
@@ -148,6 +148,8 @@ func (ctx *WorkSpaceCommand) Workflows() {
workspaceDir := filepath.Join(core.GetSublime().Root, slug.Make(ctx.Name))

releaseYaml, _ := FileTemplates.ReadFile("templates/workflow-release.yaml")
featureYaml, _ := FileTemplates.ReadFile("templates/workflow-feature.yaml")
artifactYaml, _ := FileTemplates.ReadFile("templates/workflow-artifact.yaml")

releaseYamlFile, _ := os.Create(filepath.Join(workspaceDir, ".github/workflows/release.yaml"))
releaseYamlFile.WriteString(utils.ProcessString(string(releaseYaml), &utils.ReleaseYamlVars{
@@ -158,5 +160,15 @@ func (ctx *WorkSpaceCommand) Workflows() {

color.Info.Println("❤️‍🔥 Github action release created!")

featureYamlFile, _ := os.Create(filepath.Join(workspaceDir, ".github/workflows/feature.yaml"))
featureYamlFile.WriteString(utils.ProcessString(string(featureYaml), &utils.EmptyVars{}, "[[", "]]"))

color.Info.Println("❤️‍🔥 Github action feature created!")

artifactYamlFile, _ := os.Create(filepath.Join(workspaceDir, ".github/workflows/artifact.yaml"))
artifactYamlFile.WriteString(utils.ProcessString(string(artifactYaml), &utils.EmptyVars{}, "[[", "]]"))

color.Info.Println("❤️‍🔥 Github action artifact created!")

color.Success.Println("✅ Your app is initialized. Please go into the directory an run: yarn install .")
}
21 changes: 21 additions & 0 deletions utils/git.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
Copyright © 2022 Websublime.dev [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package utils

import (
21 changes: 21 additions & 0 deletions utils/helpers.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
Copyright © 2022 Websublime.dev [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package utils

import (

0 comments on commit 35acda3

Please sign in to comment.