name: Release on: push: tags: 'v*' env: GO_VERSION: 1.17.3 jobs: prepare-sources-with-deps: name: Prepare sources with deps runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Go uses: actions/setup-go@v2 with: go-version: ${{ env.GO_VERSION }} - name: Get SFTPGo version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} - name: Prepare release run: | go mod vendor echo "${SFTPGO_VERSION}" > VERSION.txt tar cJvf sftpgo_${SFTPGO_VERSION}_src_with_deps.tar.xz * env: SFTPGO_VERSION: ${{ steps.get_version.outputs.VERSION }} - name: Upload build artifact uses: actions/upload-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.VERSION }}_src_with_deps.tar.xz path: ./sftpgo_${{ steps.get_version.outputs.VERSION }}_src_with_deps.tar.xz retention-days: 1 prepare-window-mac: name: Prepare binaries runs-on: ${{ matrix.os }} strategy: matrix: os: [macos-10.15, windows-2019] steps: - uses: actions/checkout@v2 - name: Set up Go uses: actions/setup-go@v2 with: go-version: ${{ env.GO_VERSION }} - name: Get SFTPGo version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} shell: bash - name: Get OS name id: get_os_name run: | if [[ $MATRIX_OS =~ ^macos.* ]] then echo ::set-output name=OS::macOS else echo ::set-output name=OS::windows fi shell: bash env: MATRIX_OS: ${{ matrix.os }} - name: Build for macOS x86_64 if: startsWith(matrix.os, 'windows-') != true run: go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo - 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 -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo_arm64 - name: Build for Windows if: startsWith(matrix.os, 'windows-') run: | $GIT_COMMIT = (git describe --always --dirty) | Out-String $DATE_TIME = ([datetime]::Now.ToUniversalTime().toString("yyyy-MM-ddTHH:mm:ssZ")) | Out-String $FILE_VERSION = $Env:SFTPGO_VERSION.substring(1) + ".0" go install github.com/tc-hib/go-winres@latest go-winres simply --arch amd64 --product-version $Env:SFTPGO_VERSION-$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 -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/v2/version.date=$DATE_TIME" -o sftpgo.exe env: SFTPGO_VERSION: ${{ steps.get_version.outputs.VERSION }} - name: Initialize data provider run: ./sftpgo initprovider shell: bash - name: Prepare Release for macOS if: startsWith(matrix.os, 'macos-') run: | mkdir -p output/{init,sqlite,bash_completion,zsh_completion} echo "For documentation please take a look here:" > output/README.txt echo "" >> output/README.txt echo "https://github.com/drakkan/sftpgo/blob/${SFTPGO_VERSION}/README.md" >> output/README.txt cp LICENSE output/ cp sftpgo output/ cp sftpgo.json output/ cp sftpgo.db output/sqlite/ cp -r static output/ cp -r templates 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/* cd output tar cJvf ../sftpgo_${SFTPGO_VERSION}_${OS}_x86_64.tar.xz * cd .. cp sftpgo_arm64 output/sftpgo cd output tar cJvf ../sftpgo_${SFTPGO_VERSION}_${OS}_arm64.tar.xz * cd .. env: SFTPGO_VERSION: ${{ steps.get_version.outputs.VERSION }} OS: ${{ steps.get_os_name.outputs.OS }} - name: Prepare Release for Windows if: startsWith(matrix.os, 'windows-') run: | 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 $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" $INNO_S='/Ssigntool=$qC:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.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 mkdir win-portable copy .\sftpgo.exe .\win-portable copy .\sftpgo.json .\win-portable copy .\sftpgo.db .\win-portable copy .\LICENSE .\win-portable\LICENSE.txt mkdir win-portable\templates xcopy .\templates .\win-portable\templates\ /E mkdir win-portable\static xcopy .\static .\win-portable\static\ /E & 'C:/Program Files (x86)/Windows Kits/10/bin/10.0.17763.0/x86/signtool.exe' sign /sm /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /n "Nicola Murino" /d "SFTPGo" .\win-portable\sftpgo.exe Compress-Archive .\win-portable\* sftpgo_portable_x86_64.zip certutil -delstore MY "Nicola Murino" env: SFTPGO_ISS_VERSION: ${{ steps.get_version.outputs.VERSION }} SFTPGO_ISS_DOC_URL: https://github.com/drakkan/sftpgo/blob/${{ steps.get_version.outputs.VERSION }}/README.md CERT_DATA: ${{ secrets.CERT_DATA }} CERT_PASS: ${{ secrets.CERT_PASS }} - name: Upload macOS x86_64 artifact if: startsWith(matrix.os, 'macos-') uses: actions/upload-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_x86_64.tar.xz path: ./sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_x86_64.tar.xz retention-days: 1 - name: Upload macOS arm64 artifact if: startsWith(matrix.os, 'macos-') uses: actions/upload-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_arm64.tar.xz path: ./sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_arm64.tar.xz retention-days: 1 - name: Upload Windows installer artifact if: startsWith(matrix.os, 'windows-') uses: actions/upload-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_x86_64.exe path: ./sftpgo_windows_x86_64.exe retention-days: 1 - name: Upload Windows portable artifact if: startsWith(matrix.os, 'windows-') uses: actions/upload-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_portable_x86_64.zip path: ./sftpgo_portable_x86_64.zip retention-days: 1 prepare-linux: name: Prepare Linux binaries runs-on: ubuntu-18.04 strategy: matrix: include: - arch: amd64 go-arch: amd64 deb-arch: amd64 rpm-arch: x86_64 tar-arch: x86_64 - arch: aarch64 distro: ubuntu18.04 go-arch: arm64 deb-arch: arm64 rpm-arch: aarch64 tar-arch: arm64 - arch: ppc64le distro: ubuntu18.04 go-arch: ppc64le deb-arch: ppc64el rpm-arch: ppc64le tar-arch: ppc64le - arch: armv7 distro: ubuntu18.04 go-arch: arm7 deb-arch: armhf rpm-arch: armv7hl tar-arch: armv7 steps: - uses: actions/checkout@v2 - name: Set up Go if: ${{ matrix.arch == 'amd64' }} uses: actions/setup-go@v2 with: go-version: ${{ env.GO_VERSION }} - name: Get versions id: get_version run: | echo ::set-output name=SFTPGO_VERSION::${GITHUB_REF/refs\/tags\//} echo ::set-output name=GO_VERSION::${GO_VERSION} shell: bash env: GO_VERSION: ${{ env.GO_VERSION }} - name: Build on amd64 if: ${{ matrix.arch == 'amd64' }} run: | go build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo mkdir -p output/{init,sqlite,bash_completion,zsh_completion} echo "For documentation please take a look here:" > output/README.txt echo "" >> output/README.txt echo "https://github.com/drakkan/sftpgo/blob/${SFTPGO_VERSION}/README.md" >> output/README.txt cp LICENSE output/ cp sftpgo.json output/ cp -r templates output/ cp -r static output/ cp init/sftpgo.service output/init/ ./sftpgo initprovider ./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/ cp sftpgo.db output/sqlite/ cd output tar cJvf sftpgo_${SFTPGO_VERSION}_linux_${{ matrix.tar-arch }}.tar.xz * cd .. env: SFTPGO_VERSION: ${{ steps.get_version.outputs.SFTPGO_VERSION }} - uses: uraimo/run-on-arch-action@v2.1.1 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 git xz-utils 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://golang.org/dl/go${{ steps.get_version.outputs.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 build -trimpath -ldflags "-s -w -X github.com/drakkan/sftpgo/v2/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/v2/version.date=`date -u +%FT%TZ`" -o sftpgo mkdir -p output/{init,sqlite,bash_completion,zsh_completion} echo "For documentation please take a look here:" > output/README.txt echo "" >> output/README.txt echo "https://github.com/drakkan/sftpgo/blob/${{ steps.get_version.outputs.SFTPGO_VERSION }}/README.md" >> output/README.txt cp LICENSE output/ cp sftpgo.json output/ cp -r templates output/ cp -r static output/ cp init/sftpgo.service output/init/ ./sftpgo initprovider ./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/ cp sftpgo.db output/sqlite/ cd output tar cJvf sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_${{ matrix.tar-arch }}.tar.xz * cd .. - name: Upload build artifact for ${{ matrix.arch }} uses: actions/upload-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_${{ matrix.tar-arch }}.tar.xz path: ./output/sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_${{ matrix.tar-arch }}.tar.xz retention-days: 1 - name: Build Packages id: build_linux_pkgs run: | export NFPM_ARCH=${{ matrix.go-arch }} cd pkgs ./build.sh PKG_VERSION=${SFTPGO_VERSION:1} echo "::set-output name=pkg-version::${PKG_VERSION}" env: SFTPGO_VERSION: ${{ steps.get_version.outputs.SFTPGO_VERSION }} - name: Upload Deb Package uses: actions/upload-artifact@v2 with: name: sftpgo_${{ steps.build_linux_pkgs.outputs.pkg-version }}-1_${{ matrix.deb-arch}}.deb path: ./pkgs/dist/deb/sftpgo_${{ steps.build_linux_pkgs.outputs.pkg-version }}-1_${{ matrix.deb-arch}}.deb retention-days: 1 - name: Upload RPM Package uses: actions/upload-artifact@v2 with: name: sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-1.${{ matrix.rpm-arch}}.rpm path: ./pkgs/dist/rpm/sftpgo-${{ steps.build_linux_pkgs.outputs.pkg-version }}-1.${{ matrix.rpm-arch}}.rpm retention-days: 1 prepare-linux-bundle: name: Prepare Linux bundle needs: prepare-linux runs-on: ubuntu-latest steps: - name: Get versions id: get_version run: | echo ::set-output name=SFTPGO_VERSION::${GITHUB_REF/refs\/tags\//} shell: bash - name: Download amd64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_x86_64.tar.xz - name: Download arm64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_arm64.tar.xz - name: Download ppc64le artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_ppc64le.tar.xz - name: Download armv7 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_armv7.tar.xz - name: Build bundle shell: bash run: | mkdir -p bundle/{arm64,ppc64le,armv7} cd bundle tar xvf ../sftpgo_${SFTPGO_VERSION}_linux_x86_64.tar.xz cd arm64 tar xvf ../../sftpgo_${SFTPGO_VERSION}_linux_arm64.tar.xz sftpgo cd ../ppc64le tar xvf ../../sftpgo_${SFTPGO_VERSION}_linux_ppc64le.tar.xz sftpgo cd ../armv7 tar xvf ../../sftpgo_${SFTPGO_VERSION}_linux_armv7.tar.xz sftpgo cd .. tar cJvf sftpgo_${SFTPGO_VERSION}_linux_bundle.tar.xz * cd .. env: SFTPGO_VERSION: ${{ steps.get_version.outputs.SFTPGO_VERSION }} - name: Upload Linux bundle uses: actions/upload-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_bundle.tar.xz path: ./bundle/sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_bundle.tar.xz retention-days: 1 create-release: name: Release needs: [prepare-linux-bundle, prepare-sources-with-deps, prepare-window-mac] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Get versions id: get_version run: | SFTPGO_VERSION=${GITHUB_REF/refs\/tags\//} PKG_VERSION=${SFTPGO_VERSION:1} echo ::set-output name=SFTPGO_VERSION::${SFTPGO_VERSION} echo "::set-output name=PKG_VERSION::${PKG_VERSION}" shell: bash - name: Download amd64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_x86_64.tar.xz - name: Download arm64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_arm64.tar.xz - name: Download ppc64le artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_ppc64le.tar.xz - name: Download armv7 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_armv7.tar.xz - name: Download Linux bundle artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_linux_bundle.tar.xz - name: Download Deb amd64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.PKG_VERSION }}-1_amd64.deb - name: Download Deb arm64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.PKG_VERSION }}-1_arm64.deb - name: Download Deb ppc64le artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.PKG_VERSION }}-1_ppc64el.deb - name: Download Deb armv7 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.PKG_VERSION }}-1_armhf.deb - name: Download RPM x86_64 artifact uses: actions/download-artifact@v2 with: name: sftpgo-${{ steps.get_version.outputs.PKG_VERSION }}-1.x86_64.rpm - name: Download RPM aarch64 artifact uses: actions/download-artifact@v2 with: name: sftpgo-${{ steps.get_version.outputs.PKG_VERSION }}-1.aarch64.rpm - name: Download RPM ppc64le artifact uses: actions/download-artifact@v2 with: name: sftpgo-${{ steps.get_version.outputs.PKG_VERSION }}-1.ppc64le.rpm - name: Download RPM armv7 artifact uses: actions/download-artifact@v2 with: name: sftpgo-${{ steps.get_version.outputs.PKG_VERSION }}-1.armv7hl.rpm - name: Download macOS x86_64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_macOS_x86_64.tar.xz - name: Download macOS arm64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_macOS_arm64.tar.xz - name: Download Windows installer x86_64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_windows_x86_64.exe - name: Download Windows portable x86_64 artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_windows_portable_x86_64.zip - name: Download source with deps artifact uses: actions/download-artifact@v2 with: name: sftpgo_${{ steps.get_version.outputs.SFTPGO_VERSION }}_src_with_deps.tar.xz - name: Create release run: | mv sftpgo_windows_x86_64.exe sftpgo_${SFTPGO_VERSION}_windows_x86_64.exe mv sftpgo_portable_x86_64.zip sftpgo_${SFTPGO_VERSION}_windows_portable_x86_64.zip gh release create "${SFTPGO_VERSION}" -t "${SFTPGO_VERSION}" gh release upload "${SFTPGO_VERSION}" sftpgo_*.xz --clobber gh release upload "${SFTPGO_VERSION}" sftpgo-*.rpm --clobber gh release upload "${SFTPGO_VERSION}" sftpgo_*.deb --clobber gh release upload "${SFTPGO_VERSION}" sftpgo_*.exe --clobber gh release upload "${SFTPGO_VERSION}" sftpgo_*.zip --clobber gh release view "${SFTPGO_VERSION}" env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} SFTPGO_VERSION: ${{ steps.get_version.outputs.SFTPGO_VERSION }}