diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d921d0f..31b9217 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,5 +3,8 @@ updates: - package-ecosystem: gomod directory: "/" schedule: - interval: daily - open-pull-requests-limit: 10 + interval: weekly +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: weekly \ No newline at end of file diff --git a/.github/workflows/github_release.yml b/.github/workflows/github_release.yml deleted file mode 100644 index 37a6df9..0000000 --- a/.github/workflows/github_release.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Deploy - -on: [deployment] - -jobs: - deploy: - name: Create Draft with assets - runs-on: macos-latest - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 - with: - go-version: 1.13 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v1 - - - name: Build artifacts - run: | - go run build/make.go --all-platforms - go run build/make.go --all-platforms --distro - - - name: Install hub - run: brew install hub - - - name: update - run: | - cd deploy - if [ -z "$version" ]; then - version=$(ls screenshot* | head -1 | sed "s/\.[^\.]*$//" | sed "s/screenshot-//" | sed | sed "s/-[a-z]*\.[a-z0-9_]*$//"); - fi - artifacts=() - dir=`pwd` - for i in `ls`; do - artifacts+="$dir/$i " - done - cd .. - echo "---------------------------" - echo "Updating release v$version" - echo "---------------------------" - echo -e "Gauge Screenshot v$version\n\n" > desc.txt - release_description=$(ruby -e "$(curl -sSfL https://github.com/getgauge/gauge/raw/master/build/create_release_text.rb)" getgauge gauge_screenshot) - echo "$release_description" >> desc.txt - echo "Creating new draft for release v$version" - hub release create -d -F ./desc.txt "v$version" - rm -rf desc.txt - echo "Start uploading assets..." - for i in `ls $artifacts`; do - hub release edit -m "" -a $i "v$version" - if [ $? -ne 0 ];then - exit 1 - fi - done - - name: "deployment success" - if: success() - uses: "deliverybot/status@master" - with: - state: "success" - token: "${{ secrets.GITHUB_TOKEN }}" - - - name: "deployment failure" - if: failure() - uses: "deliverybot/status@master" - with: - state: "failure" - token: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.github/workflows/release-on-pr-merge.yml b/.github/workflows/release-on-pr-merge.yml new file mode 100644 index 0000000..c898603 --- /dev/null +++ b/.github/workflows/release-on-pr-merge.yml @@ -0,0 +1,50 @@ +name: Release on PR Merge + +on: deployment + +jobs: + deploy: + if: github.event.deployment.environment == 'production' + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: '${{ secrets.GAUGEBOT_GITHUB_TOKEN }}' + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Setup git + run: | + git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)" + git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)" + + - name: Build artifacts + run: | + go run build/make.go --all-platforms + go run build/make.go --all-platforms --distro + + - name: update + run: | + if [ -z "$version" ]; then + version=$(cd deploy && ls screenshot* | head -1 | sed "s/\.[^\.]*$//" | sed "s/screenshot-//" | sed | sed "s/-[a-z]*\.[a-z0-9_]*$//"); + fi + echo "VERSION=$version" >> $GITHUB_ENV + + echo "---------------------------" + echo "Updating release v$version" + echo "---------------------------" + echo -e "Gauge Screenshot v$version\n\n" > desc.txt + release_description=$(ruby -e "$(curl -sSfL https://github.com/getgauge/gauge/raw/master/build/create_release_text.rb)" getgauge gauge_screenshot) + echo "$release_description" >> desc.txt + gh release create --title "Gauge Screenshot v${version}" --notes-file ./desc.txt "v${version}" deploy/* + + - name: Update metadata in gauge-repository + run: | + git clone https://github.com/getgauge/gauge-repository.git + cd gauge-repository + python update_metadata.py screenshot $VERSION + commit_message=$(echo -e "Update screenshot to v$VERSION") + git commit -am "$commit_message" + git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/getgauge/gauge-repository.git" master diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index be34566..2cbb922 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,14 +9,12 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 - with: - go-version: 1.13 - id: go + - uses: actions/checkout@v4 - - name: Check out code into the Go module directory - uses: actions/checkout@v1 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' - name: Test run: go test ./... \ No newline at end of file diff --git a/build/make.go b/build/make.go index 89ef75b..e531fe3 100644 --- a/build/make.go +++ b/build/make.go @@ -23,7 +23,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "log" "os" "os/exec" @@ -33,10 +32,7 @@ import ( ) const ( - CGO_ENABLED = "CGO_ENABLED" -) - -const ( + CGO_ENABLED = "CGO_ENABLED" dotGauge = ".gauge" plugins = "plugins" GOARCH = "GOARCH" @@ -75,7 +71,7 @@ func compile() { if *allPlatforms { compileAcrossPlatforms() } else { - compileGoPackage(screenshot) + compileGoPackage() } } @@ -180,7 +176,7 @@ func mirrorDir(src, dst string) error { } suffix, err := filepath.Rel(src, path) if err != nil { - return fmt.Errorf("Failed to find Rel(%q, %q): %v", src, path, err) + return fmt.Errorf("failed to find Rel(%q, %q): %v", src, path, err) } return mirrorFile(path, filepath.Join(dst, suffix)) }) @@ -204,7 +200,7 @@ func executeCommand(command string, arg ...string) (string, error) { return strings.TrimSpace(fmt.Sprintf("%s", bytes)), err } -func compileGoPackage(packageName string) { +func compileGoPackage() { runProcess("go", "build", "-o", getGaugeExecutablePath(gaugeScreenshot)) } @@ -280,24 +276,23 @@ var binDir = flag.String("bin-dir", "", "Specifies OS_PLATFORM specific binaries var ( platformEnvs = []map[string]string{ - map[string]string{GOARCH: x86, goOS: DARWIN, CGO_ENABLED: "0"}, map[string]string{GOARCH: x86_64, goOS: DARWIN, CGO_ENABLED: "0"}, - map[string]string{GOARCH: x86, goOS: LINUX, CGO_ENABLED: "0"}, + map[string]string{GOARCH: ARM64, goOS: DARWIN, CGO_ENABLED: "0"}, map[string]string{GOARCH: x86_64, goOS: LINUX, CGO_ENABLED: "0"}, map[string]string{GOARCH: ARM64, goOS: LINUX, CGO_ENABLED: "0"}, - map[string]string{GOARCH: x86, goOS: WINDOWS, CC: "i586-mingw32-gcc", CGO_ENABLED: "1"}, map[string]string{GOARCH: x86_64, goOS: WINDOWS, CC: "x86_64-w64-mingw32-gcc", CGO_ENABLED: "1"}, + map[string]string{GOARCH: ARM64, goOS: WINDOWS, CC: "aarch64-w64-mingw32-gcc", CGO_ENABLED: "1"}, } ) func getPluginProperties(jsonPropertiesFile string) (map[string]interface{}, error) { - pluginPropertiesJson, err := ioutil.ReadFile(jsonPropertiesFile) + pluginPropertiesJson, err := os.ReadFile(jsonPropertiesFile) if err != nil { fmt.Printf("Could not read %s: %s\n", filepath.Base(jsonPropertiesFile), err) return nil, err } var pluginJson interface{} - if err = json.Unmarshal([]byte(pluginPropertiesJson), &pluginJson); err != nil { + if err = json.Unmarshal(pluginPropertiesJson, &pluginJson); err != nil { fmt.Printf("Could not read %s: %s\n", filepath.Base(jsonPropertiesFile), err) return nil, err } @@ -309,7 +304,7 @@ func compileAcrossPlatforms() { setEnv(platformEnv) fmt.Printf("Compiling for platform => OS:%s ARCH:%s \n", platformEnv[goOS], platformEnv[GOARCH]) runProcess("go", "get", "./...") - compileGoPackage(screenshot) + compileGoPackage() } } @@ -361,10 +356,10 @@ func getGOARCH() string { } func getGOOS() string { - os := os.Getenv(goOS) - if os == "" { + goOs := os.Getenv(goOS) + if goOs == "" { return runtime.GOOS } - return os + return goOs } diff --git a/go.mod b/go.mod index dc3ebce..124474e 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/getgauge/gauge_screenshot -go 1.13 +go 1.22 require ( - github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 - github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf + github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc + github.com/TheTitanrain/w32 v0.0.0-20200114052255-2654d97dbd3d ) diff --git a/go.sum b/go.sum index 2d081f7..18610cd 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,4 @@ -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf h1:FPsprx82rdrX2jiKyS17BH6IrTmUBYqZa/CXT4uvb+I= -github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf/go.mod h1:peYoMncQljjNS6tZwI9WVyQB3qZS6u79/N3mBOcnd3I= +github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc h1:7D+Bh06CRPCJO3gr2F7h1sriovOZ8BMhca2Rg85c2nk= +github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/TheTitanrain/w32 v0.0.0-20200114052255-2654d97dbd3d h1:2xp1BQbqcDDaikHnASWpVZRjibOxu7y9LhAv04whugI= +github.com/TheTitanrain/w32 v0.0.0-20200114052255-2654d97dbd3d/go.mod h1:peYoMncQljjNS6tZwI9WVyQB3qZS6u79/N3mBOcnd3I= diff --git a/plugin.json b/plugin.json index 4b2af64..6bca0f6 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "id" : "screenshot", - "version" : "0.1.0", + "version" : "0.2.0", "name" : "Screenshot", "description" : "cross-platform command line screenshot utility", "scope" : [], diff --git a/release.sh b/release.sh deleted file mode 100755 index 346d69c..0000000 --- a/release.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -if [ -z "$GITHUB_TOKEN" ]; then - echo "GITHUB_TOKEN is not set." - echo "Please create an personal access token with repo:public_repo scopes." - exit 1 -fi - -curl \ - -X POST \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.ant-man-preview+json" \ - -H "Content-Type: application/json" \ - https://api.github.com/repos/getgauge/gauge_screenshot/deployments \ - --data '{"ref": "master", "required_contexts": [], "environment": "production"}' \ No newline at end of file diff --git a/version/version.go b/version/version.go index db70057..4b4e29a 100644 --- a/version/version.go +++ b/version/version.go @@ -18,4 +18,4 @@ package version -var Version = "0.1.0" +var Version = "0.2.0"