| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525 |
- name: CI
- on:
- push:
- branches: [main]
- pull_request:
- jobs:
- test-deploy:
- name: Test and deploy
- runs-on: ${{ matrix.os }}
- strategy:
- matrix:
- go: ['1.20']
- os: [ubuntu-latest, macos-latest]
- upload-coverage: [true]
- include:
- - go: '1.20'
- os: windows-latest
- upload-coverage: false
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
- - name: Set up Go
- uses: actions/setup-go@v4
- with:
- go-version: ${{ matrix.go }}
- - name: Build for Linux/macOS x86_64
- if: startsWith(matrix.os, 'windows-') != true
- run: |
- go build -trimpath -tags nopgxregisterdefaulttypes -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --abbrev=8 --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo
- cd tests/eventsearcher
- go build -trimpath -ldflags "-s -w" -o eventsearcher
- cd -
- cd tests/ipfilter
- go build -trimpath -ldflags "-s -w" -o ipfilter
- cd -
- ./sftpgo initprovider
- ./sftpgo resetprovider --force
- - name: Build for macOS arm64
- if: startsWith(matrix.os, 'macos-') == true
- run: CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 SDKROOT=$(xcrun --sdk macosx --show-sdk-path) go build -trimpath -tags nopgxregisterdefaulttypes -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --abbrev=8 --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo_arm64
- - name: Build for Windows
- if: startsWith(matrix.os, 'windows-')
- run: |
- $GIT_COMMIT = (git describe --always --abbrev=8 --dirty) | Out-String
- $DATE_TIME = ([datetime]::Now.ToUniversalTime().toString("yyyy-MM-ddTHH:mm:ssZ")) | Out-String
- $LATEST_TAG = ((git describe --tags $(git rev-list --tags --max-count=1)) | Out-String).Trim()
- $REV_LIST=$LATEST_TAG+"..HEAD"
- $COMMITS_FROM_TAG= ((git rev-list $REV_LIST --count) | Out-String).Trim()
- $FILE_VERSION = $LATEST_TAG.substring(1) + "." + $COMMITS_FROM_TAG
- go install github.com/tc-hib/go-winres@latest
- go-winres simply --arch amd64 --product-version $LATEST_TAG-dev-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico
- go build -trimpath -tags nopgxregisterdefaulttypes -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o sftpgo.exe
- cd tests/eventsearcher
- go build -trimpath -ldflags "-s -w" -o eventsearcher.exe
- cd ../..
- cd tests/ipfilter
- go build -trimpath -ldflags "-s -w" -o ipfilter.exe
- cd ../..
- mkdir arm64
- $Env:CGO_ENABLED='0'
- $Env:GOOS='windows'
- $Env:GOARCH='arm64'
- go-winres simply --arch arm64 --product-version $LATEST_TAG-dev-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico
- go build -trimpath -tags nopgxregisterdefaulttypes,nosqlite -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o .\arm64\sftpgo.exe
- mkdir x86
- $Env:GOARCH='386'
- go-winres simply --arch 386 --product-version $LATEST_TAG-dev-$GIT_COMMIT --file-version $FILE_VERSION --file-description "SFTPGo server" --product-name SFTPGo --copyright "AGPL-3.0" --original-filename sftpgo.exe --icon .\windows-installer\icon.ico
- go build -trimpath -tags nopgxregisterdefaulttypes,nosqlite -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/internal/version.date=$DATE_TIME" -o .\x86\sftpgo.exe
- Remove-Item Env:\CGO_ENABLED
- Remove-Item Env:\GOOS
- Remove-Item Env:\GOARCH
- - name: Run test cases using SQLite provider
- run: go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 15m ./... -coverprofile=coverage.txt -covermode=atomic
- - name: Upload coverage to Codecov
- if: ${{ matrix.upload-coverage }}
- uses: codecov/codecov-action@v3
- with:
- file: ./coverage.txt
- fail_ci_if_error: false
- - name: Run test cases using bolt provider
- run: |
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 2m ./internal/config -covermode=atomic
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 5m ./internal/common -covermode=atomic
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 5m ./internal/httpd -covermode=atomic
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 8m ./internal/sftpd -covermode=atomic
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 5m ./internal/ftpd -covermode=atomic
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 5m ./internal/webdavd -covermode=atomic
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 2m ./internal/telemetry -covermode=atomic
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 2m ./internal/mfa -covermode=atomic
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 2m ./internal/command -covermode=atomic
- env:
- SFTPGO_DATA_PROVIDER__DRIVER: bolt
- SFTPGO_DATA_PROVIDER__NAME: 'sftpgo_bolt.db'
- - name: Run test cases using memory provider
- run: go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 15m ./... -covermode=atomic
- env:
- SFTPGO_DATA_PROVIDER__DRIVER: memory
- SFTPGO_DATA_PROVIDER__NAME: ''
- - name: Prepare build artifact for macOS
- if: startsWith(matrix.os, 'macos-') == true
- run: |
- mkdir -p output/{init,bash_completion,zsh_completion}
- cp sftpgo output/sftpgo_x86_64
- cp sftpgo_arm64 output/
- cp sftpgo.json output/
- cp -r templates output/
- cp -r static output/
- cp -r openapi output/
- cp init/com.github.drakkan.sftpgo.plist output/init/
- ./sftpgo gen completion bash > output/bash_completion/sftpgo
- ./sftpgo gen completion zsh > output/zsh_completion/_sftpgo
- ./sftpgo gen man -d output/man/man1
- gzip output/man/man1/*
- - name: Prepare Windows installer
- if: ${{ startsWith(matrix.os, 'windows-') && github.event_name != 'pull_request' }}
- run: |
- Remove-Item -LiteralPath "output" -Force -Recurse -ErrorAction Ignore
- mkdir output
- copy .\sftpgo.exe .\output
- copy .\sftpgo.json .\output
- copy .\sftpgo.db .\output
- copy .\LICENSE .\output\LICENSE.txt
- mkdir output\templates
- xcopy .\templates .\output\templates\ /E
- mkdir output\static
- xcopy .\static .\output\static\ /E
- mkdir output\openapi
- xcopy .\openapi .\output\openapi\ /E
- $LATEST_TAG = ((git describe --tags $(git rev-list --tags --max-count=1)) | Out-String).Trim()
- $REV_LIST=$LATEST_TAG+"..HEAD"
- $COMMITS_FROM_TAG= ((git rev-list $REV_LIST --count) | Out-String).Trim()
- $Env:SFTPGO_ISS_DEV_VERSION = $LATEST_TAG + "." + $COMMITS_FROM_TAG
- $CERT_PATH=(Get-Location -PSProvider FileSystem).ProviderPath + "\cert.pfx"
- [IO.File]::WriteAllBytes($CERT_PATH,[System.Convert]::FromBase64String($Env:CERT_DATA))
- certutil -f -p "$Env:CERT_PASS" -importpfx MY "$CERT_PATH"
- rm "$CERT_PATH"
- & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x86/signtool.exe' sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n "Nicola Murino" /d "SFTPGo" .\sftpgo.exe
- & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x86/signtool.exe' sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n "Nicola Murino" /d "SFTPGo" .\arm64\sftpgo.exe
- & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x86/signtool.exe' sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n "Nicola Murino" /d "SFTPGo" .\x86\sftpgo.exe
- $INNO_S='/Ssigntool=$qC:/Program Files (x86)/Windows Kits/10/bin/10.0.20348.0/x86/signtool.exe$q sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n $qNicola Murino$q /d $qSFTPGo$q $f'
- iscc "$INNO_S" .\windows-installer\sftpgo.iss
- rm .\output\sftpgo.exe
- rm .\output\sftpgo.db
- copy .\arm64\sftpgo.exe .\output
- (Get-Content .\output\sftpgo.json).replace('"sqlite"', '"bolt"') | Set-Content .\output\sftpgo.json
- $Env:SFTPGO_DATA_PROVIDER__DRIVER='bolt'
- $Env:SFTPGO_DATA_PROVIDER__NAME='.\output\sftpgo.db'
- .\sftpgo.exe initprovider
- Remove-Item Env:\SFTPGO_DATA_PROVIDER__DRIVER
- Remove-Item Env:\SFTPGO_DATA_PROVIDER__NAME
- $Env:SFTPGO_ISS_ARCH='arm64'
- iscc "$INNO_S" .\windows-installer\sftpgo.iss
- rm .\output\sftpgo.exe
- copy .\x86\sftpgo.exe .\output
- $Env:SFTPGO_ISS_ARCH='x86'
- iscc "$INNO_S" .\windows-installer\sftpgo.iss
- certutil -delstore MY "Nicola Murino"
- env:
- CERT_DATA: ${{ secrets.CERT_DATA }}
- CERT_PASS: ${{ secrets.CERT_PASS }}
- - name: Upload Windows installer x86_64 artifact
- if: ${{ startsWith(matrix.os, 'windows-') && github.event_name != 'pull_request' }}
- uses: actions/upload-artifact@v3
- with:
- name: sftpgo_windows_installer_x86_64
- path: ./sftpgo_windows_x86_64.exe
- - name: Upload Windows installer arm64 artifact
- if: ${{ startsWith(matrix.os, 'windows-') && github.event_name != 'pull_request' }}
- uses: actions/upload-artifact@v3
- with:
- name: sftpgo_windows_installer_arm64
- path: ./sftpgo_windows_arm64.exe
- - name: Upload Windows installer x86 artifact
- if: ${{ startsWith(matrix.os, 'windows-') && github.event_name != 'pull_request' }}
- uses: actions/upload-artifact@v3
- with:
- name: sftpgo_windows_installer_x86
- path: ./sftpgo_windows_x86.exe
- - name: Prepare build artifact for Windows
- if: startsWith(matrix.os, 'windows-')
- run: |
- Remove-Item -LiteralPath "output" -Force -Recurse -ErrorAction Ignore
- mkdir output
- copy .\sftpgo.exe .\output
- mkdir output\arm64
- copy .\arm64\sftpgo.exe .\output\arm64
- mkdir output\x86
- copy .\x86\sftpgo.exe .\output\x86
- copy .\sftpgo.json .\output
- (Get-Content .\output\sftpgo.json).replace('"sqlite"', '"bolt"') | Set-Content .\output\sftpgo.json
- mkdir output\templates
- xcopy .\templates .\output\templates\ /E
- mkdir output\static
- xcopy .\static .\output\static\ /E
- mkdir output\openapi
- xcopy .\openapi .\output\openapi\ /E
- - name: Upload build artifact
- if: startsWith(matrix.os, 'ubuntu-') != true
- uses: actions/upload-artifact@v3
- with:
- name: sftpgo-${{ matrix.os }}-go-${{ matrix.go }}
- path: output
- test-build-flags:
- name: Test build flags
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - name: Set up Go
- uses: actions/setup-go@v4
- with:
- go-version: '1.20'
- - name: Build
- run: |
- go build -trimpath -tags nopgxregisterdefaulttypes,nogcs,nos3,noportable,nobolt,nomysql,nopgsql,nosqlite,nometrics,noazblob,unixcrypt -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/internal/version.commit=`git describe --always --abbrev=8 --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo
- ./sftpgo -v
- cp -r openapi static templates internal/bundle/
- go build -trimpath -tags nopgxregisterdefaulttypes,bundle -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --abbrev=8 --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo
- ./sftpgo -v
- test-postgresql-mysql-crdb:
- name: Test with PgSQL/MySQL/Cockroach
- runs-on: ubuntu-latest
- services:
- postgres:
- image: postgres:latest
- env:
- POSTGRES_PASSWORD: postgres
- POSTGRES_DB: sftpgo
- options: >-
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
- ports:
- - 5432:5432
- mariadb:
- image: mariadb:latest
- env:
- MYSQL_ROOT_PASSWORD: mysql
- MYSQL_DATABASE: sftpgo
- MYSQL_USER: sftpgo
- MYSQL_PASSWORD: sftpgo
- options: >-
- --health-cmd "mariadb-admin status -h 127.0.0.1 -P 3306 -u root -p$MYSQL_ROOT_PASSWORD"
- --health-interval 10s
- --health-timeout 5s
- --health-retries 6
- ports:
- - 3307:3306
- mysql:
- image: mysql:latest
- env:
- MYSQL_ROOT_PASSWORD: mysql
- MYSQL_DATABASE: sftpgo
- MYSQL_USER: sftpgo
- MYSQL_PASSWORD: sftpgo
- options: >-
- --health-cmd "mysqladmin status -h 127.0.0.1 -P 3306 -u root -p$MYSQL_ROOT_PASSWORD"
- --health-interval 10s
- --health-timeout 5s
- --health-retries 6
- ports:
- - 3308:3306
- steps:
- - uses: actions/checkout@v3
- - name: Set up Go
- uses: actions/setup-go@v4
- with:
- go-version: '1.20'
- - name: Build
- run: |
- go build -trimpath -tags nopgxregisterdefaulttypes -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=`git describe --always --abbrev=8 --dirty` -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo
- cd tests/eventsearcher
- go build -trimpath -ldflags "-s -w" -o eventsearcher
- cd -
- cd tests/ipfilter
- go build -trimpath -ldflags "-s -w" -o ipfilter
- cd -
- - name: Run tests using MySQL provider
- run: |
- ./sftpgo initprovider
- ./sftpgo resetprovider --force
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 15m ./... -covermode=atomic
- env:
- SFTPGO_DATA_PROVIDER__DRIVER: mysql
- SFTPGO_DATA_PROVIDER__NAME: sftpgo
- SFTPGO_DATA_PROVIDER__HOST: localhost
- SFTPGO_DATA_PROVIDER__PORT: 3308
- SFTPGO_DATA_PROVIDER__USERNAME: sftpgo
- SFTPGO_DATA_PROVIDER__PASSWORD: sftpgo
- - name: Run tests using PostgreSQL provider
- run: |
- ./sftpgo initprovider
- ./sftpgo resetprovider --force
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 15m ./... -covermode=atomic
- env:
- SFTPGO_DATA_PROVIDER__DRIVER: postgresql
- SFTPGO_DATA_PROVIDER__NAME: sftpgo
- SFTPGO_DATA_PROVIDER__HOST: localhost
- SFTPGO_DATA_PROVIDER__PORT: 5432
- SFTPGO_DATA_PROVIDER__USERNAME: postgres
- SFTPGO_DATA_PROVIDER__PASSWORD: postgres
- - name: Run tests using MariaDB provider
- run: |
- ./sftpgo initprovider
- ./sftpgo resetprovider --force
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 15m ./... -covermode=atomic
- env:
- SFTPGO_DATA_PROVIDER__DRIVER: mysql
- SFTPGO_DATA_PROVIDER__NAME: sftpgo
- SFTPGO_DATA_PROVIDER__HOST: localhost
- SFTPGO_DATA_PROVIDER__PORT: 3307
- SFTPGO_DATA_PROVIDER__USERNAME: sftpgo
- SFTPGO_DATA_PROVIDER__PASSWORD: sftpgo
- SFTPGO_DATA_PROVIDER__SQL_TABLES_PREFIX: prefix_
- - name: Run tests using CockroachDB provider
- run: |
- docker run --rm --name crdb --health-cmd "curl -I http://127.0.0.1:8080" --health-interval 10s --health-timeout 5s --health-retries 6 -p 26257:26257 -d cockroachdb/cockroach:latest start-single-node --insecure --listen-addr :26257
- sleep 10
- docker exec crdb cockroach sql --insecure -e 'create database "sftpgo"'
- ./sftpgo initprovider
- ./sftpgo resetprovider --force
- go test -v -tags nopgxregisterdefaulttypes -p 1 -timeout 15m ./... -covermode=atomic
- docker stop crdb
- env:
- SFTPGO_DATA_PROVIDER__DRIVER: cockroachdb
- SFTPGO_DATA_PROVIDER__NAME: sftpgo
- SFTPGO_DATA_PROVIDER__HOST: localhost
- SFTPGO_DATA_PROVIDER__PORT: 26257
- SFTPGO_DATA_PROVIDER__USERNAME: root
- SFTPGO_DATA_PROVIDER__PASSWORD:
- SFTPGO_DATA_PROVIDER__TARGET_SESSION_ATTRS: any
- SFTPGO_DATA_PROVIDER__SQL_TABLES_PREFIX: prefix_
- build-linux-packages:
- name: Build Linux packages
- runs-on: ubuntu-latest
- strategy:
- matrix:
- include:
- - arch: amd64
- distro: ubuntu:18.04
- go: latest
- go-arch: amd64
- - arch: aarch64
- distro: ubuntu18.04
- go: latest
- go-arch: arm64
- - arch: ppc64le
- distro: ubuntu18.04
- go: latest
- go-arch: ppc64le
- - arch: armv7
- distro: ubuntu18.04
- go: latest
- go-arch: arm7
- steps:
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
- - name: Get commit SHA
- id: get_commit
- run: echo "COMMIT=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
- shell: bash
- - name: Build on amd64
- if: ${{ matrix.arch == 'amd64' }}
- run: |
- echo '#!/bin/bash' > build.sh
- echo '' >> build.sh
- echo 'set -e' >> build.sh
- echo 'apt-get update -q -y' >> build.sh
- echo 'apt-get install -q -y curl gcc' >> build.sh
- if [ ${{ matrix.go }} == 'latest' ]
- then
- echo 'GO_VERSION=$(curl -L https://go.dev/VERSION?m=text)' >> build.sh
- else
- echo 'GO_VERSION=${{ matrix.go }}' >> build.sh
- fi
- echo 'GO_DOWNLOAD_ARCH=${{ matrix.go-arch }}' >> build.sh
- echo 'curl --retry 5 --retry-delay 2 --connect-timeout 10 -o go.tar.gz -L https://go.dev/dl/${GO_VERSION}.linux-${GO_DOWNLOAD_ARCH}.tar.gz' >> build.sh
- echo 'tar -C /usr/local -xzf go.tar.gz' >> build.sh
- echo 'export PATH=$PATH:/usr/local/go/bin' >> build.sh
- echo 'go version' >> build.sh
- echo 'cd /usr/local/src' >> build.sh
- echo 'go build -buildvcs=false -trimpath -tags nopgxregisterdefaulttypes -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=${{ steps.get_commit.outputs.COMMIT }} -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo' >> build.sh
- chmod 755 build.sh
- docker run --rm --name ubuntu-build --mount type=bind,source=`pwd`,target=/usr/local/src ${{ matrix.distro }} /usr/local/src/build.sh
- mkdir -p output/{init,bash_completion,zsh_completion}
- cp sftpgo.json output/
- cp -r templates output/
- cp -r static output/
- cp -r openapi output/
- cp init/sftpgo.service output/init/
- ./sftpgo gen completion bash > output/bash_completion/sftpgo
- ./sftpgo gen completion zsh > output/zsh_completion/_sftpgo
- ./sftpgo gen man -d output/man/man1
- gzip output/man/man1/*
- cp sftpgo output/
- - uses: uraimo/run-on-arch-action@v2
- if: ${{ matrix.arch != 'amd64' }}
- name: Build for ${{ matrix.arch }}
- id: build
- with:
- arch: ${{ matrix.arch }}
- distro: ${{ matrix.distro }}
- setup: |
- mkdir -p "${PWD}/output"
- dockerRunArgs: |
- --volume "${PWD}/output:/output"
- shell: /bin/bash
- install: |
- apt-get update -q -y
- apt-get install -q -y curl gcc
- if [ ${{ matrix.go }} == 'latest' ]
- then
- GO_VERSION=$(curl -L https://go.dev/VERSION?m=text)
- else
- GO_VERSION=${{ matrix.go }}
- fi
- GO_DOWNLOAD_ARCH=${{ matrix.go-arch }}
- if [ ${{ matrix.arch}} == 'armv7' ]
- then
- GO_DOWNLOAD_ARCH=armv6l
- fi
- curl --retry 5 --retry-delay 2 --connect-timeout 10 -o go.tar.gz -L https://go.dev/dl/${GO_VERSION}.linux-${GO_DOWNLOAD_ARCH}.tar.gz
- tar -C /usr/local -xzf go.tar.gz
- run: |
- export PATH=$PATH:/usr/local/go/bin
- go version
- if [ ${{ matrix.arch}} == 'armv7' ]
- then
- export GOARM=7
- fi
- go build -buildvcs=false -trimpath -tags nopgxregisterdefaulttypes -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/internal/version.commit=${{ steps.get_commit.outputs.COMMIT }} -X github.com/drakkan/sftpgo/v2/internal/version.date=`date -u +%FT%TZ`" -o sftpgo
- mkdir -p output/{init,bash_completion,zsh_completion}
- cp sftpgo.json output/
- cp -r templates output/
- cp -r static output/
- cp -r openapi output/
- cp init/sftpgo.service output/init/
- ./sftpgo gen completion bash > output/bash_completion/sftpgo
- ./sftpgo gen completion zsh > output/zsh_completion/_sftpgo
- ./sftpgo gen man -d output/man/man1
- gzip output/man/man1/*
- cp sftpgo output/
- - name: Upload build artifact
- uses: actions/upload-artifact@v3
- with:
- name: sftpgo-linux-${{ matrix.arch }}-go-${{ matrix.go }}
- path: output
- - name: Build Packages
- id: build_linux_pkgs
- run: |
- export NFPM_ARCH=${{ matrix.go-arch }}
- cd pkgs
- ./build.sh
- PKG_VERSION=$(cat dist/version)
- echo "pkg-version=${PKG_VERSION}" >> $GITHUB_OUTPUT
- - name: Upload Debian Package
- uses: actions/upload-artifact@v3
- with:
- name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-${{ matrix.go-arch }}-deb
- path: pkgs/dist/deb/*
- - name: Upload RPM Package
- uses: actions/upload-artifact@v3
- with:
- name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-${{ matrix.go-arch }}-rpm
- path: pkgs/dist/rpm/*
- golangci-lint:
- name: golangci-lint
- runs-on: ubuntu-latest
- steps:
- - name: Set up Go
- uses: actions/setup-go@v4
- with:
- go-version: '1.20'
- - uses: actions/checkout@v3
- - name: Run golangci-lint
- uses: golangci/golangci-lint-action@v3
- with:
- version: latest
|