diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7295ad86..f4cfbd2b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,8 +1,6 @@ name: release for roller on: push: - branches: - - 'main' tags: - 'v*' jobs: @@ -22,7 +20,7 @@ jobs: release-type: go package-name: roller prerelease: true - prerelease-label: beta + prerelease-label: alpha changelog-types: >- [ @@ -36,20 +34,24 @@ jobs: # token must have repo write permissions ( https://github.com/googleapis/release-please/blob/main/docs/cli.md#create-a-manifest-pull-request-deprecated ) token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/checkout@v4 + if: steps.release-please.outputs.release_created with: fetch-depth: '0' - name: Set up Go uses: actions/setup-go@v5 + if: steps.release-please.outputs.release_created with: check-latest: true go-version-file: go.mod - name: Setup release environment + if: steps.release-please.outputs.release_created env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: |- echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env - name: Release publish + if: steps.release-please.outputs.release_created run: make release diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index fda87aad..36e2def3 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" "os" - "os/exec" "path/filepath" "runtime" "strconv" @@ -19,7 +18,6 @@ import ( "github.com/dymensionxyz/roller/relayer" "github.com/dymensionxyz/roller/sequencer" globalutils "github.com/dymensionxyz/roller/utils" - "github.com/dymensionxyz/roller/utils/bash" configutils "github.com/dymensionxyz/roller/utils/config" "github.com/dymensionxyz/roller/utils/config/tomlconfig" "github.com/dymensionxyz/roller/utils/config/yamlconfig" @@ -123,24 +121,11 @@ func Cmd() *cobra.Command { pterm.Info.Println("removing old systemd services") for _, svc := range consts.RelayerSystemdServices { svcFileName := fmt.Sprintf("%s.service", svc) - pterm.Info.Printf("removing %s", svcFileName) svcFilePath := filepath.Join("/etc/systemd/system/", svcFileName) - c := exec.Command("sudo", "systemctl", "stop", svcFileName) - _, err := bash.ExecCommandWithStdout(c) - if err != nil { - pterm.Error.Printf("failed to remove systemd services: %v\n", err) - return - } - c = exec.Command("sudo", "systemctl", "disable", svcFileName) - _, err = bash.ExecCommandWithStdout(c) - if err != nil { - pterm.Error.Printf("failed to remove systemd services: %v\n", err) - return - } - c = exec.Command("sudo", "rm", svcFilePath) - _, err = bash.ExecCommandWithStdout(c) + + err := globalutils.RemoveFileIfExists(svcFilePath) if err != nil { - pterm.Error.Printf("failed to remove systemd services: %v\n", err) + pterm.Error.Println("failed to remove systemd service: ", err) return } } diff --git a/cmd/rollapp/init/init.go b/cmd/rollapp/init/init.go index a74d66fa..3d6ffec3 100644 --- a/cmd/rollapp/init/init.go +++ b/cmd/rollapp/init/init.go @@ -49,8 +49,36 @@ func Cmd() *cobra.Command { var hd consts.HubData var env string + dymdBinaryOptions := dependencies.Dependency{ + Name: "dymension", + Repository: "https://github.com/artemijspavlovs/dymension", + Release: "3.1.0-pg04", + Binaries: []dependencies.BinaryPathPair{ + { + Binary: "dymd", + BinaryDestination: consts.Executables.Dymension, + BuildCommand: exec.Command( + "make", + "build", + ), + }, + }, + } + + pterm.Info.Println("installing dependencies") + err = installBinaryFromRelease(dymdBinaryOptions) + if err != nil { + pterm.Error.Println("failed to install dymd: ", err) + return + } + if shouldUseMockBackend { env := "mock" + err = installBinaries("mock", true) + if err != nil { + pterm.Error.Println("failed to install binaries: ", err) + return + } err := runInit(cmd, env, raID) if err != nil { fmt.Println("failed to run init: ", err) @@ -67,6 +95,11 @@ func Cmd() *cobra.Command { Show() hd = consts.Hubs[env] if env == "mock" { + err = installBinaries("mock", true) + if err != nil { + pterm.Error.Println("failed to install binaries: ", err) + return + } err := runInit(cmd, env, raID) if err != nil { fmt.Println("failed to run init: ", err) @@ -77,28 +110,6 @@ func Cmd() *cobra.Command { } // ex binaries install - dymdBinaryOptions := dependencies.Dependency{ - Name: "dymension", - Repository: "https://github.com/artemijspavlovs/dymension", - Release: "3.1.0-pg04", - Binaries: []dependencies.BinaryPathPair{ - { - Binary: "dymd", - BinaryDestination: consts.Executables.Dymension, - BuildCommand: exec.Command( - "make", - "build", - ), - }, - }, - } - - pterm.Info.Println("installing dependencies") - err = installBinaryFromRelease(dymdBinaryOptions) - if err != nil { - pterm.Error.Println("failed to install dymd: ", err) - return - } raID = strings.TrimSpace(raID) @@ -121,7 +132,7 @@ func Cmd() *cobra.Command { pterm.Error.Println("no bech") return } - err = installBinaries(raResponse.Rollapp.GenesisInfo.Bech32Prefix) + err = installBinaries(raResponse.Rollapp.GenesisInfo.Bech32Prefix, false) if err != nil { pterm.Error.Println("failed to install binaries: ", err) return @@ -177,7 +188,7 @@ func Cmd() *cobra.Command { return cmd } -func installBinaries(bech32 string) error { +func installBinaries(bech32 string, withMockDA bool) error { c := exec.Command("sudo", "mkdir", "-p", consts.InternalBinsDir) _, err := bash.ExecCommandWithStdout(c) if err != nil { @@ -223,7 +234,10 @@ func installBinaries(bech32 string) error { }, }, }, - "celestia": { + } + + if !withMockDA { + buildableDeps["celestia"] = dependencies.Dependency{ Repository: "https://github.com/celestiaorg/celestia-node.git", Release: "v0.16.0", Binaries: []dependencies.BinaryPathPair{ @@ -244,7 +258,7 @@ func installBinaries(bech32 string) error { ), }, }, - }, + } } goreleaserDeps := map[string]dependencies.Dependency{ diff --git a/cmd/rollapp/init/utils.go b/cmd/rollapp/init/utils.go index 50a3a5bf..1b6981ae 100644 --- a/cmd/rollapp/init/utils.go +++ b/cmd/rollapp/init/utils.go @@ -71,21 +71,9 @@ func runInit(cmd *cobra.Command, env string, raID string) error { pterm.Info.Println("removing old systemd services") for _, svc := range consts.RollappSystemdServices { svcFileName := fmt.Sprintf("%s.service", svc) - pterm.Info.Printf("removing %s", svcFileName) - svcFilePath := filepath.Join("/etc/systemd/system/", svcFileName) - c := exec.Command("sudo", "systemctl", "stop", svcFileName) - _, err := bash.ExecCommandWithStdout(c) - if err != nil { - return err - } - c = exec.Command("sudo", "systemctl", "disable", svcFileName) - _, err = bash.ExecCommandWithStdout(c) - if err != nil { - return err - } - c = exec.Command("sudo", "rm", svcFilePath) - _, err = bash.ExecCommandWithStdout(c) + + err := globalutils.RemoveFileIfExists(svcFilePath) if err != nil { return err } diff --git a/utils/filesystem.go b/utils/filesystem.go index b41e102a..46ae973a 100644 --- a/utils/filesystem.go +++ b/utils/filesystem.go @@ -212,3 +212,19 @@ func ExtractTarGz(sourcePath, destDir string) error { spinner.Success("Archive extracted successfully") return nil } + +func RemoveFileIfExists(filePath string) error { + _, err := os.Stat(filePath) + if err == nil { + err := os.Remove(filePath) + if err != nil { + return fmt.Errorf("failed to remove file: %w", err) + } + fmt.Printf("File %s has been removed\n", filePath) + } else if os.IsNotExist(err) { + fmt.Printf("File %s does not exist\n", filePath) + } else { + return fmt.Errorf("error checking file: %w", err) + } + return nil +}