Skip to content

Commit

Permalink
INTG-2739 new build (#396)
Browse files Browse the repository at this point in the history
* INTG-2739 re-build

* INTG-2739 revert postgres

* INTG-2739 restruct

* INTG-2739 restruct

* INTG-2739 typo

* INTG-2739 try without -w

* INTG-2739 try new go-releaser

* INTG-2739 try new go-releaser

* INTG-2739 revert

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 try new build

* INTG-2739 enable cgo

* INTG-2739 enable cgo

* INTG-2739 small changes

* INTG-2739 small changes

* INTG-2739 small changes

* INTG-2739 small changes

* INTG-2739 linting

* INTG-2739 linting

* INTG-2739 linting

* INTG-2739 prepared for signing mac

* INTG-2739 prepared for signing mac

* INTG-2739 prepared for signing mac

* INTG-2739 prepared for signing mac

* INTG-2739 prepared for signing mac

* INTG-2739 prepared for signing mac

* INTG-2739 prepared for signing mac

* INTG-2739 prepared for signing mac

* INTG-2739 linting

* INTG-2739 change file names
  • Loading branch information
MickStanciu authored Apr 12, 2023
1 parent 6f7f639 commit 66d6e7a
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 216 deletions.
165 changes: 165 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# yamllint disable rule:line-length
---
name: package

# yamllint disable-line rule:truthy
on:
push:
tags:
- "v*.*.*"

jobs:
package:
strategy:
matrix:
build-os: [ubuntu-latest, macOS-latest]
platform: [linux-amd64, windows-amd64, darwin-amd64, darwin-arm64]
runs-on: ${{ matrix.build-os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.20.2

- name: Checkout code
uses: actions/checkout@v2

- name: Install linux dependencies
if: ${{ matrix.build-os == 'ubuntu-latest' }}
run: sudo apt-get update -y && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config gcc-mingw-w64 zip

- name: Build packages windows-amd64
if: ${{ matrix.platform == 'windows-amd64' && matrix.build-os == 'ubuntu-latest' }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
echo "building for ${{ matrix.platform }}"
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -v -ldflags "-s -w -X github.com/SafetyCulture/safetyculture-exporter/internal/app/version.version=${{ github.ref_name }}" -o safetyculture-exporter.exe ./cmd/safetyculture-exporter/main.go
mkdir safetyculture-exporter-cli
cp safetyculture-exporter.exe README.md THIRD_PARTY_NOTICES.md safetyculture-exporter-cli/
zip -r safetyculture-exporter-windows-x86_64.zip safetyculture-exporter-cli
rm -rf safetyculture-exporter-cli
- name: Upload artifacts windows-amd64
if: ${{ matrix.platform == 'windows-amd64' && matrix.build-os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v2
with:
name: exporter-windows-amd64
path: safetyculture-exporter-windows-x86_64.zip

- name: Build package linux-amd64
if: ${{ matrix.platform == 'linux-amd64' && matrix.build-os == 'ubuntu-latest' }}
run: |
export PATH=$PATH:$(go env GOPATH)/bin
echo "building for ${{ matrix.platform }}"
GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -v -ldflags "-s -w -X github.com/SafetyCulture/safetyculture-exporter/internal/app/version.version=${{ github.ref_name }}" -o safetyculture-exporter ./cmd/safetyculture-exporter/main.go
zip safetyculture-exporter_linux_x86_64.zip exporter-linux README.md THIRD_PARTY_NOTICES.md
mkdir safetyculture-exporter-cli
cp safetyculture-exporter README.md THIRD_PARTY_NOTICES.md safetyculture-exporter-cli/
zip -r safetyculture-exporter-linux-amd64.zip safetyculture-exporter-cli
rm -rf safetyculture-exporter-cli
- name: Upload artifacts linux-amd64
if: ${{ matrix.platform == 'linux-amd64' && matrix.build-os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v2
with:
name: exporter-linux-amd64
path: safetyculture-exporter-linux-amd64.zip

- name: Build package darwin-amd64
if: ${{ matrix.platform == 'darwin-amd64' && matrix.build-os == 'macOS-latest' }}
env:
MAC_SIGNING_CERT: ${{ secrets.MAC_SIGNING_CERT }}
run: |
echo "Importing certificates"
echo $MAC_SIGNING_CERT | base64 --decode > certificate.p12
security create-keychain -p ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
security import certificate.p12 -k build.keychain -P ${{ secrets.MAC_SIGNING_CERT_PASSWORD }} -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
export PATH=$PATH:$(go env GOPATH)/bin
echo "building for ${{ matrix.platform }}"
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -v -ldflags "-s -w -X github.com/SafetyCulture/safetyculture-exporter/internal/app/version.version=${{ github.ref_name }}" -o safetyculture-exporter ./cmd/safetyculture-exporter/main.go
echo "Code signing darwin/amd64"
codesign --force -s "${{ secrets.MAC_SIGNING_CERT_NAME }}" --options runtime ./safetyculture-exporter -v
mkdir safetyculture-exporter-cli
cp safetyculture-exporter README.md THIRD_PARTY_NOTICES.md safetyculture-exporter-cli/
zip -r safetyculture-exporter-darwin-amd64.zip safetyculture-exporter-cli
rm -rf safetyculture-exporter-cli
- name: Upload artifacts darwin-amd64
if: ${{ matrix.platform == 'darwin-amd64' && matrix.build-os == 'macOS-latest' }}
uses: actions/upload-artifact@v2
with:
name: exporter-darwin-amd64
path: safetyculture-exporter-darwin-amd64.zip

- name: Build package darwin-arm64
if: ${{ matrix.platform == 'darwin-arm64' && matrix.build-os == 'macOS-latest' }}
env:
MAC_SIGNING_CERT: ${{ secrets.MAC_SIGNING_CERT }}
run: |
echo "Importing certificates"
echo $MAC_SIGNING_CERT | base64 --decode > certificate.p12
security create-keychain -p ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
security import certificate.p12 -k build.keychain -P ${{ secrets.MAC_SIGNING_CERT_PASSWORD }} -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k ${{ secrets.MAC_SIGNING_KEYCHAIN_PWD }} build.keychain
export PATH=$PATH:$(go env GOPATH)/bin
echo "building for ${{ matrix.platform }}"
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 go build -v -ldflags "-s -w -X github.com/SafetyCulture/safetyculture-exporter/internal/app/version.version=${{ github.ref_name }}" -o safetyculture-exporter ./cmd/safetyculture-exporter/main.go
echo "Code signing darwin/arm64"
codesign --force -s "${{ secrets.MAC_SIGNING_CERT_NAME }}" --options runtime ./safetyculture-exporter -v
mkdir safetyculture-exporter-cli
cp safetyculture-exporter README.md THIRD_PARTY_NOTICES.md safetyculture-exporter-cli/
zip -r safetyculture-exporter-darwin-arm64.zip safetyculture-exporter-cli
rm -rf safetyculture-exporter-cli
- name: Upload artifacts darwin-arm64
if: ${{ matrix.platform == 'darwin-arm64' && matrix.build-os == 'macOS-latest' }}
uses: actions/upload-artifact@v2
with:
name: exporter-darwin-arm64
path: safetyculture-exporter-darwin-arm64.zip

release:
runs-on: ubuntu-latest
needs: package
steps:
- name: Download package windows amd64
uses: actions/download-artifact@v2
with:
name: exporter-windows-amd64

- name: Download package darwin amd64
uses: actions/download-artifact@v2
with:
name: exporter-darwin-amd64

- name: Download package darwin arm64
uses: actions/download-artifact@v2
with:
name: exporter-darwin-arm64

- name: Download package linux amd64
uses: actions/download-artifact@v2
with:
name: exporter-linux-amd64

- name: Create Release
id: create_release
uses: ncipollo/release-action@v1
with:
token: "${{ secrets.GITHUB_TOKEN }}"
artifacts: "safetyculture-exporter-windows-x86_64.zip,safetyculture-exporter-darwin-arm64.zip,safetyculture-exporter-darwin-amd64.zip,safetyculture-exporter-linux-amd64.zip"
allowUpdates: true
prerelease: true
draft: true
makeLatest: false
33 changes: 0 additions & 33 deletions .github/workflows/goreleaser.yml

This file was deleted.

116 changes: 0 additions & 116 deletions .goreleaser.yml

This file was deleted.

35 changes: 0 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,3 @@ soak-tests:
TEST_API_HOST="https://api.safetyculture.io" TEST_DB_DIALECT="mysql" TEST_DB_CONN_STRING="root:safetyculture_exporter@tcp(localhost:3308)/safetyculture_exporter_db?charset=utf8mb4&parseTime=True&loc=Local" go test ./... -tags=soak
TEST_API_HOST="https://api.safetyculture.io" TEST_DB_DIALECT="sqlserver" TEST_DB_CONN_STRING="sqlserver://sa:SafetyCultureExporter12345@localhost:1433?database=master" go test ./... -tags=soak
TEST_API_HOST="https://api.safetyculture.io" TEST_DB_DIALECT="sqlite" TEST_DB_CONN_STRING="file::memory:" go test ./... -tags=soak

.PHONY: release-snapshot
release-snapshot:
docker run \
--rm \
--privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
-f .goreleaser.yml --rm-dist --snapshot --skip-validate --skip-publish

.PHONY: release-dry-run
release-dry-run:
docker run \
--rm \
--privileged \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
-f .goreleaser.yml --rm-dist --skip-validate --skip-publish

.PHONY: release
release:
docker run \
--rm \
--privileged \
--entrypoint ./goreleaser_entry.sh \
--env-file .release-env \
-v /var/run/docker.sock:/var/run/docker.sock \
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
-f .goreleaser.yml release --rm-dist
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ Acceptable versions include `v3.0.0`, `v3.0.0-alpha.22`, `v3.0.0-prealpha.22`, `
4. Push your tag to GitHub\
`git push origin v3.0.0`
5. Update the [release draft](https://github.com/SafetyCulture/safetyculture-exporter/releases) and publish it!
6. Upload the exe file to https://www.virustotal.com and check for false positives
2 changes: 1 addition & 1 deletion cmd/safetyculture-exporter/cmd/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Cmd() *cobra.Command {
}
}

func generateYamlConfiguration(cmd *cobra.Command, args []string) error {
func generateYamlConfiguration(*cobra.Command, []string) error {
cm := exporterAPI.NewConfigurationManager("", viper.ConfigFileUsed())
err := cm.SaveConfiguration()
util.Check(err, "while writing config to file")
Expand Down
Loading

0 comments on commit 66d6e7a

Please sign in to comment.