Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upload manifest file to be able to find the archive name and move the archive to the dist folder #5

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
name: archives
path: |
**/*.tar.gz
**/mf-manifest.json
!node_modules

lint:
Expand Down
17 changes: 13 additions & 4 deletions scripts/build-archive/build-archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
}
}
}
2 changes: 1 addition & 1 deletion scripts/upload-archive/upload-archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Loading