diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 189ca15..ede7414 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,7 @@ jobs: name: archives path: | **/*.tar.gz + **/mf-manifest.json !node_modules lint: diff --git a/scripts/build-archive/build-archive.go b/scripts/build-archive/build-archive.go index 4b985a6..2aaf531 100644 --- a/scripts/build-archive/build-archive.go +++ b/scripts/build-archive/build-archive.go @@ -26,13 +26,22 @@ func createArchive(pluginName string) error { distPath := path.Join(pluginName, "dist") manifest, err := npm.ReadManifest(pluginName) if err != nil { - logrus.Fatal(err) + return err } newArchiveFolder := path.Join(pluginName, manifest.ID) + // Let's copy the dist folder just to ensure we have the correct folder name for the archive if execErr := exec.Command("cp", "-r", distPath, newArchiveFolder).Run(); execErr != nil { + return fmt.Errorf("unable to copy the dist folder to the path %s: %w", newArchiveFolder, execErr) + } + // Then let's create the archive with the folder previously created + archiveName := fmt.Sprintf("%s.tar.gz", manifest.ID) + if execErr := exec.Command("tar", "-czvf", path.Join(pluginName, archiveName), newArchiveFolder).Run(); execErr != nil { return execErr } - if execErr := exec.Command("tar", "-czvf", path.Join(pluginName, fmt.Sprintf("%s.tar.gz", manifest.ID)), newArchiveFolder).Run(); execErr != nil { + + // Finally, move the archive to the dist folder, + // so it will be straightforward to find it back during the release process. + if execErr := exec.Command("mv", path.Join(pluginName, archiveName), distPath).Run(); execErr != nil { return execErr } return exec.Command("rm", "-rf", newArchiveFolder).Run() @@ -41,12 +50,12 @@ func createArchive(pluginName string) error { func main() { workspaces, err := npm.GetWorkspaces() if err != nil { - logrus.Fatal(err) + logrus.WithError(err).Fatal("unable to get the list of the workspaces") } for _, workspace := range workspaces { logrus.Infof("building archive for the plugin %s", workspace) if createArchiveErr := createArchive(workspace); createArchiveErr != nil { - logrus.Fatal(err) + logrus.WithError(createArchiveErr).Fatalf("unable to generate the archive for the plugin %s", workspace) } } } diff --git a/scripts/upload-archive/upload-archive.go b/scripts/upload-archive/upload-archive.go index 65446ee..0d7f2a9 100644 --- a/scripts/upload-archive/upload-archive.go +++ b/scripts/upload-archive/upload-archive.go @@ -38,7 +38,7 @@ func main() { if err != nil { logrus.Fatal(err) } - if execErr := exec.Command("gh", "release", "upload", *tag, path.Join(pluginName, fmt.Sprintf("%s.tar.gz", manifest.ID))).Run(); execErr != nil { + if execErr := exec.Command("gh", "release", "upload", *tag, path.Join(pluginName, "dist", fmt.Sprintf("%s.tar.gz", manifest.ID))).Run(); execErr != nil { logrus.WithError(err).Fatalf("unable to upload archive %s", pluginName) } }