diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..cfce5a1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,52 @@ +name: build + +on: push + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + cache: true + + - name: Test + run: go test -v -coverpkg ./... ./... | tee test.out + + - name: Publish test and coverage metrics + uses: gaelgirodon/ci-badges-action@v1 + with: + gist-id: fbde4d59b7dd3c4f2cc9c4fea3497ae1 + token: ${{ secrets.GIST_TOKEN }} + + - name: Build (Linux) + run: go build -ldflags="-s -w" -o "propencrypt" "cmd/propencrypt.go" + env: { GOARCH: amd64, GOOS: linux } + + - name: Build (Windows) + run: go build -ldflags="-s -w" -o "propencrypt.exe" "cmd/propencrypt.go" + env: { GOARCH: amd64, GOOS: windows } + + - name: Package (Linux) + run: | + archive=propencrypt_linux_amd64.tar.gz + tar zcvf "${archive}" propencrypt + sha256sum "${archive}" | cut -d' ' -f 1 > "${archive}.sha256" + + - name: Package (Windows) + shell: pwsh + run: | + $archive = 'propencrypt_windows_amd64.zip' + Compress-Archive 'propencrypt.exe' -DestinationPath "$archive" -CompressionLevel 'Optimal' + $hash = (Get-FileHash -Algorithm 'SHA256' "$archive").Hash.ToLower() + Set-Content -Path "$archive.sha256" -Value "$hash`n" -Encoding 'ascii' -NoNewline + + - name: Publish artifacts + uses: actions/upload-artifact@v3 + with: + name: propencrypt + path: propencrypt_*_*.* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index a3e9527..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,52 +0,0 @@ -# -# .gitlab-ci.yml -# - -stages: - - test - - build - - package - -workflow: - rules: [ if: $CI_COMMIT_BRANCH ] - -test: - stage: test - image: golang:1.19 - script: - - go test -v -coverpkg ./... ./... - coverage: '/coverage: [0-9.]+%/' - -build: - stage: build - image: golang:1.19 - script: - - GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o "propencrypt" "cmd/propencrypt.go" - - GOARCH=amd64 GOOS=windows go build -ldflags="-s -w" -o "propencrypt.exe" "cmd/propencrypt.go" - artifacts: - paths: [ "propencrypt", "propencrypt.exe" ] - expire_in: 1 week - -package:linux: - stage: package - image: buildpack-deps - script: - - archive=propencrypt_linux_amd64.tar.gz - - tar zcvf "${archive}" propencrypt - - sha256sum "${archive}" | cut -d' ' -f 1 > "${archive}.sha256" - artifacts: - paths: [ "propencrypt_linux_amd64.tar.gz*" ] - expire_in: 1 week - -package:windows: - stage: package - image: mcr.microsoft.com/powershell - script: - - pwsh -NoLogo -NoProfile -Command " - \$archive = 'propencrypt_windows_amd64.zip'; - Compress-Archive 'propencrypt.exe' -DestinationPath \"\$archive\" -CompressionLevel 'Optimal'; - \$hash = (Get-FileHash -Algorithm 'SHA256' \"\$archive\").Hash.ToLower(); - Set-Content -Path \"\$archive.sha256\" -Value \"\$hash\`n\" -Encoding 'ascii' -NoNewline" - artifacts: - paths: [ "propencrypt_windows_amd64.zip*" ] - expire_in: 1 week diff --git a/README.md b/README.md index a3ebe56..8ccec3c 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,9 @@ [![release](https://img.shields.io/github/v/release/GaelGirodon/propencrypt?style=flat-square)](https://github.com/GaelGirodon/propencrypt/releases/latest) [![license](https://img.shields.io/github/license/GaelGirodon/propencrypt?color=blue&style=flat-square)](./LICENSE) -[![build](https://img.shields.io/gitlab/pipeline/GaelGirodon/propencrypt/master?style=flat-square)](https://gitlab.com/GaelGirodon/propencrypt/-/pipelines/latest) -[![coverage](https://img.shields.io/gitlab/coverage/GaelGirodon/propencrypt/master?style=flat-square)](https://gitlab.com/GaelGirodon/propencrypt/-/pipelines/latest) +[![build](https://img.shields.io/github/workflow/status/GaelGirodon/propencrypt/build?style=flat-square)](https://github.com/GaelGirodon/propencrypt/actions/workflows/build.yml) +[![tests](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fgist.githubusercontent.com%2FGaelGirodon%2Ffbde4d59b7dd3c4f2cc9c4fea3497ae1%2Fraw%2Fpropencrypt-go-tests.json)](https://github.com/GaelGirodon/propencrypt/actions/workflows/build.yml) +[![coverage](https://img.shields.io/endpoint?style=flat-square&url=https%3A%2F%2Fgist.githubusercontent.com%2FGaelGirodon%2Ffbde4d59b7dd3c4f2cc9c4fea3497ae1%2Fraw%2Fpropencrypt-go-coverage.json)](https://github.com/GaelGirodon/propencrypt/actions/workflows/build.yml) [![docker](https://img.shields.io/docker/v/gaelgirodon/propencrypt?color=blue&label=docker&logo=docker&logoColor=white&style=flat-square)](https://hub.docker.com/r/gaelgirodon/propencrypt) Encrypt and decrypt multiple properties, in multiple files, at once.