From c2b835d2f2a0c5727b3667e8a57f07d1274aafaf Mon Sep 17 00:00:00 2001 From: "Ali R. Vahdati" Date: Mon, 26 Feb 2024 15:13:38 +0100 Subject: [PATCH 1/8] Compile binaries in artifacts Add instructions to compile binaries Change loop syntax for Windows builds Fix typo Fix variable declaration Update the build command for Windows Fix the APPS list for PowerShell --- .github/workflows/go.yml | 68 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 33a74f3..3d29cbe 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -48,3 +48,71 @@ jobs: - name: Test run: go test -v ./... + + build-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ^1.21 + + - name: Get dependencies + run: go get -v ./... + + - name: Build for Linux + run: | + PREFIX="build" + OS="linux" + APPS="datasetArchiver datasetGetProposal datasetRetriever datasetIngestor datasetCleaner" + + for GOOS in $OS; do + OUT="$PREFIX/$GOOS" + mkdir -p "$OUT" + for APP in $APPS; do + GOOS=$GOOS GOARCH=amd64 go build -o "$OUT/$APP" "./cmd/$APP" + done + done + + - name: Archive binaries + uses: actions/upload-artifact@v2 + with: + name: binaries + path: build + + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: ^1.21 + + - name: Get dependencies + run: go get -v ./... + + - name: Build for Windows + run: | + $PREFIX="build" + $OS="windows" + $APPS="datasetArchiver", "datasetGetProposal", "datasetRetriever", "datasetIngestor", "datasetCleaner" + + foreach ($GOOS in $OS) { + $OUT="$PREFIX/$GOOS" + mkdir -p "$OUT" + foreach ($APP in $APPS){ + $env:GOOS=$GOOS + $env:GOARCH="amd64" + go build -o "$OUT/$APP.exe" "./cmd/$APP" + } + } + + - name: Archive binaries + uses: actions/upload-artifact@v2 + with: + name: binaries + path: build \ No newline at end of file From b371242d693ee500a8785ecbb088cd3eedae375e Mon Sep 17 00:00:00 2001 From: "Ali R. Vahdati" Date: Wed, 6 Mar 2024 14:07:52 +0100 Subject: [PATCH 2/8] Add newline at the end of file --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 3d29cbe..2cbad67 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -115,4 +115,4 @@ jobs: uses: actions/upload-artifact@v2 with: name: binaries - path: build \ No newline at end of file + path: build From e0ce8ad346e6f93b27bfad9919fc56e1e06e7243 Mon Sep 17 00:00:00 2001 From: "Ali R. Vahdati" Date: Wed, 6 Mar 2024 14:40:28 +0100 Subject: [PATCH 3/8] Remove the OS loops --- .github/workflows/go.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2cbad67..5b7698d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -68,12 +68,10 @@ jobs: OS="linux" APPS="datasetArchiver datasetGetProposal datasetRetriever datasetIngestor datasetCleaner" - for GOOS in $OS; do - OUT="$PREFIX/$GOOS" - mkdir -p "$OUT" - for APP in $APPS; do - GOOS=$GOOS GOARCH=amd64 go build -o "$OUT/$APP" "./cmd/$APP" - done + OUT="$PREFIX/$OS" + mkdir -p "$OUT" + for APP in $APPS; do + GOOS=$GOOS GOARCH=amd64 go build -o "$OUT/$APP" "./cmd/$APP" done - name: Archive binaries @@ -101,14 +99,12 @@ jobs: $OS="windows" $APPS="datasetArchiver", "datasetGetProposal", "datasetRetriever", "datasetIngestor", "datasetCleaner" - foreach ($GOOS in $OS) { - $OUT="$PREFIX/$GOOS" - mkdir -p "$OUT" - foreach ($APP in $APPS){ - $env:GOOS=$GOOS - $env:GOARCH="amd64" - go build -o "$OUT/$APP.exe" "./cmd/$APP" - } + $OUT="$PREFIX/$OS" + mkdir -p "$OUT" + foreach ($APP in $APPS){ + $env:GOOS=$GOOS + $env:GOARCH="amd64" + go build -o "$OUT/$APP.exe" "./cmd/$APP" } - name: Archive binaries From 89625b119b7906108753978c3b81f53257eabd89 Mon Sep 17 00:00:00 2001 From: "Ali R. Vahdati" Date: Tue, 12 Mar 2024 14:14:13 +0100 Subject: [PATCH 4/8] Use goreleaser --- .github/workflows/go.yml | 67 --------------------- .github/workflows/release.yml | 35 +++++++++++ .gitignore | 3 +- .goreleaser.yaml | 110 ++++++++++++++++++++++++++++++++++ go.mod | 10 +++- go.sum | 25 -------- 6 files changed, 156 insertions(+), 94 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 5b7698d..4cf8b31 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,6 +1,3 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - name: Go on: @@ -48,67 +45,3 @@ jobs: - name: Test run: go test -v ./... - - build-linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: ^1.21 - - - name: Get dependencies - run: go get -v ./... - - - name: Build for Linux - run: | - PREFIX="build" - OS="linux" - APPS="datasetArchiver datasetGetProposal datasetRetriever datasetIngestor datasetCleaner" - - OUT="$PREFIX/$OS" - mkdir -p "$OUT" - for APP in $APPS; do - GOOS=$GOOS GOARCH=amd64 go build -o "$OUT/$APP" "./cmd/$APP" - done - - - name: Archive binaries - uses: actions/upload-artifact@v2 - with: - name: binaries - path: build - - build-windows: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: ^1.21 - - - name: Get dependencies - run: go get -v ./... - - - name: Build for Windows - run: | - $PREFIX="build" - $OS="windows" - $APPS="datasetArchiver", "datasetGetProposal", "datasetRetriever", "datasetIngestor", "datasetCleaner" - - $OUT="$PREFIX/$OS" - mkdir -p "$OUT" - foreach ($APP in $APPS){ - $env:GOOS=$GOOS - $env:GOARCH="amd64" - go build -o "$OUT/$APP.exe" "./cmd/$APP" - } - - - name: Archive binaries - uses: actions/upload-artifact@v2 - with: - name: binaries - path: build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8bcd5e0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +# .github/workflows/release.yml +name: goreleaser + +on: + pull_request: + push: + # run only against tags + tags: + - "*" + +permissions: + contents: write + # packages: write + # issues: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index c795b05..be611cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -build \ No newline at end of file +build +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..02cea67 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,110 @@ +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + + +# Test with `goreleaser --snapshot --clean` +# To release, create a tag and push it to Github: `git tag -a v0.1.0 -m "First release" && git push origin v0.1.0`. GoReleaser enforces semantic versioning and will error on non-compliant tags. +# For it to work, you need to have the `GITHUB_TOKEN` environment variable set export GITHUB_TOKEN="YOUR_GH_TOKEN". The minimum permissions the GITHUB_TOKEN should have to run this are write:packages + +# Now you can run GoReleaser at the root of your repository: `goreleaser release` +# For dry run, see https://goreleaser.com/quick-start/#dry-run + +version: 1 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... + +builds: + - id: "datasetIngestor" + env: + - CGO_ENABLED=0 + dir: ./cmd/datasetIngestor/ + goos: + - linux + - windows + - darwin + goarch: + - amd64 + main: . + binary: datasetIngestor + + - id: "datasetArchiver" + env: + - CGO_ENABLED=0 + dir: ./cmd/datasetArchiver/ + goos: + - linux + - windows + - darwin + goarch: + - amd64 + main: . + binary: datasetArchiver + + - id: "datasetRetriever" + env: + - CGO_ENABLED=0 + dir: ./cmd/datasetRetriever/ + goos: + - linux + - windows + - darwin + goarch: + - amd64 + main: . + binary: datasetRetriever + + - id: "datasetCleaner" + env: + - CGO_ENABLED=0 + dir: ./cmd/datasetCleaner/ + goos: + - linux + - windows + - darwin + goarch: + - amd64 + main: . + binary: datasetCleaner + + - id: "datasetGetProposal" + env: + - CGO_ENABLED=0 + dir: ./cmd/datasetGetProposal/ + goos: + - linux + - windows + - darwin + goarch: + - amd64 + main: . + binary: datasetGetProposal + + +archives: + - format: tar.gz + name_template: >- + {{ .ProjectName }}_ + {{ .Version }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" diff --git a/go.mod b/go.mod index bb27753..310bd18 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module scicat -go 1.15 +go 1.21 require ( github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 @@ -10,3 +10,11 @@ require ( golang.org/x/crypto v0.3.0 gopkg.in/yaml.v2 v2.4.0 ) + +require ( + github.com/creack/pty v1.1.17 // indirect + github.com/mattn/go-colorable v0.1.9 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + golang.org/x/sys v0.2.0 // indirect + golang.org/x/term v0.2.0 // indirect +) diff --git a/go.sum b/go.sum index 38bdff9..00500b7 100644 --- a/go.sum +++ b/go.sum @@ -20,40 +20,15 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= From afbbf301d02887d194c01780c3ac68f9bfda60c4 Mon Sep 17 00:00:00 2001 From: "Ali R. Vahdati" Date: Tue, 12 Mar 2024 14:19:30 +0100 Subject: [PATCH 5/8] Fix conflicts --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index be611cf..d17a1f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build dist/ +*.un~ +*~ \ No newline at end of file From 47c59ed63ee14fea056cf85bfde0b6d73f8bc81c Mon Sep 17 00:00:00 2001 From: "Ali R. Vahdati" <3798865+kavir1698@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:57:09 +0100 Subject: [PATCH 6/8] Don't run on pull requests Since deploying and creating a new release are typically actions you would want to do after code has been reviewed and merged, triggering on a pull request results to errors. --- .github/workflows/release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8bcd5e0..6e6df53 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,6 @@ -# .github/workflows/release.yml name: goreleaser on: - pull_request: push: # run only against tags tags: From 438773977efd187b8a08f279e51b447a7910e4f6 Mon Sep 17 00:00:00 2001 From: "Ali R. Vahdati" <3798865+kavir1698@users.noreply.github.com> Date: Tue, 12 Mar 2024 15:02:15 +0100 Subject: [PATCH 7/8] Temp changes to test release.yml --- .github/workflows/release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e6df53..9c9aa40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,8 @@ name: goreleaser on: push: - # run only against tags + branches: + - autocompile tags: - "*" @@ -28,6 +29,6 @@ jobs: with: distribution: goreleaser version: latest - args: release --clean + args: release --snapshot --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b2294dad5ccb29050d5d4da5ced9079d79adbb5d Mon Sep 17 00:00:00 2001 From: Ali Vahdati Date: Thu, 14 Mar 2024 10:58:27 +0100 Subject: [PATCH 8/8] Revert temp changes --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c9aa40..1e77e4c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,9 +3,9 @@ name: goreleaser on: push: branches: - - autocompile + - main tags: - - "*" + - "v*" permissions: contents: write @@ -29,6 +29,6 @@ jobs: with: distribution: goreleaser version: latest - args: release --snapshot --clean + args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}