2020-06-29 09:15:24 +00:00
|
|
|
name: Release
|
2020-06-28 13:57:33 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags: 'v*'
|
|
|
|
|
|
|
|
env:
|
2020-06-29 09:15:24 +00:00
|
|
|
GO_VERSION: 1.14
|
2020-06-28 13:57:33 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
create-release:
|
2020-06-29 09:15:24 +00:00
|
|
|
name: Create
|
2020-06-28 13:57:33 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Create Release
|
|
|
|
id: create_release
|
|
|
|
uses: actions/create-release@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
tag_name: ${{ github.ref }}
|
|
|
|
release_name: Release ${{ github.ref }}
|
|
|
|
draft: false
|
|
|
|
prerelease: false
|
|
|
|
|
|
|
|
- name: Save release upload URL
|
|
|
|
run: echo "${{ steps.create_release.outputs.upload_url }}" > ./upload_url.txt
|
|
|
|
shell: bash
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Store release upload URL
|
2020-06-28 13:57:33 +00:00
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: upload_url
|
|
|
|
path: ./upload_url.txt
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
release-sources-with-deps:
|
|
|
|
name: Publish sources
|
2020-06-28 13:57:33 +00:00
|
|
|
needs: create-release
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Set up Go
|
2020-06-28 13:57:33 +00:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2020-06-29 09:15:24 +00:00
|
|
|
go-version: ${{ env.GO_VERSION }}
|
2020-06-28 13:57:33 +00:00
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Get SFTPGo version
|
2020-06-28 13:57:33 +00:00
|
|
|
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 }}
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Download release upload URL
|
|
|
|
uses: actions/download-artifact@v2
|
2020-06-28 13:57:33 +00:00
|
|
|
with:
|
|
|
|
name: upload_url
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Get release upload URL
|
2020-06-28 13:57:33 +00:00
|
|
|
id: upload_url
|
|
|
|
run: |
|
|
|
|
URL=$(cat upload_url.txt)
|
|
|
|
echo "::set-output name=url::${URL}"
|
|
|
|
shell: bash
|
|
|
|
|
|
|
|
- name: Upload Release
|
|
|
|
id: upload-release-asset
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ steps.upload_url.outputs.url }}
|
|
|
|
asset_path: ./sftpgo_${{ steps.get_version.outputs.VERSION }}_src_with_deps.tar.xz
|
|
|
|
asset_name: sftpgo_${{ steps.get_version.outputs.VERSION }}_src_with_deps.tar.xz
|
|
|
|
asset_content_type: application/x-xz
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
publish:
|
|
|
|
name: Publish binary
|
2020-06-28 13:57:33 +00:00
|
|
|
needs: create-release
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Set up Go
|
2020-06-28 13:57:33 +00:00
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
2020-06-29 09:15:24 +00:00
|
|
|
go-version: ${{ env.GO_VERSION }}
|
2020-06-28 13:57:33 +00:00
|
|
|
|
|
|
|
- name: Set up Python
|
|
|
|
if: startsWith(matrix.os, 'windows-')
|
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: 3.x
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Build for Linux/macOS
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-') != true
|
|
|
|
run: go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=`git describe --always --dirty` -X github.com/drakkan/sftpgo/version.date=`date -u +%FT%TZ`" -o sftpgo
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Build for Windows
|
2020-06-28 13:57:33 +00:00
|
|
|
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
|
|
|
|
go build -i -ldflags "-s -w -X github.com/drakkan/sftpgo/version.commit=$GIT_COMMIT -X github.com/drakkan/sftpgo/version.date=$DATE_TIME" -o sftpgo.exe
|
|
|
|
|
|
|
|
- name: Initialize data provider
|
|
|
|
run: ./sftpgo initprovider
|
|
|
|
shell: bash
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Get SFTPGo version
|
2020-06-28 13:57:33 +00:00
|
|
|
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 == 'ubuntu-latest' ]
|
|
|
|
then
|
|
|
|
echo ::set-output name=OS::linux
|
|
|
|
elif [ $MATRIX_OS == 'macos-latest' ]
|
|
|
|
then
|
|
|
|
echo ::set-output name=OS::macOS
|
|
|
|
else
|
|
|
|
echo ::set-output name=OS::windows
|
|
|
|
fi
|
|
|
|
shell: bash
|
|
|
|
env:
|
|
|
|
MATRIX_OS: ${{ matrix.os }}
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Build REST API CLI for Windows
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-')
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip setuptools wheel
|
|
|
|
pip install requests
|
|
|
|
pip install pygments
|
|
|
|
pip install pyinstaller
|
|
|
|
pyinstaller --hidden-import="pkg_resources.py2_warn" --noupx --onefile examples\rest-api-cli\sftpgo_api_cli.py
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Prepare Release for Linux/macOS
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-') != true
|
|
|
|
run: |
|
|
|
|
mkdir -p output/{init,examples/rest-api-cli,sqlite}
|
|
|
|
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/
|
|
|
|
if [ $OS == 'linux' ]
|
|
|
|
then
|
|
|
|
cp -r init/sftpgo.service output/init/
|
|
|
|
else
|
|
|
|
cp -r init/com.github.drakkan.sftpgo.plist output/init/
|
|
|
|
fi
|
|
|
|
cp examples/rest-api-cli/sftpgo_api_cli.py output/examples/rest-api-cli/
|
|
|
|
cd output
|
|
|
|
tar cJvf sftpgo_${SFTPGO_VERSION}_${OS}_x86_64.tar.xz *
|
|
|
|
cd ..
|
|
|
|
env:
|
|
|
|
SFTPGO_VERSION: ${{ steps.get_version.outputs.VERSION }}
|
|
|
|
OS: ${{ steps.get_os_name.outputs.OS }}
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Prepare Release for Windows
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-')
|
|
|
|
run: |
|
|
|
|
mkdir output
|
|
|
|
copy .\sftpgo.exe .\output
|
|
|
|
copy .\sftpgo.json .\output
|
|
|
|
copy .\sftpgo.db .\output
|
|
|
|
copy .\dist\sftpgo_api_cli.exe .\output
|
|
|
|
copy .\LICENSE .\output\LICENSE.txt
|
|
|
|
mkdir output\templates
|
|
|
|
xcopy .\templates .\output\templates\ /E
|
|
|
|
mkdir output\static
|
|
|
|
xcopy .\static .\output\static\ /E
|
|
|
|
iscc windows-installer\sftpgo.iss
|
|
|
|
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
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Download release upload URL
|
|
|
|
uses: actions/download-artifact@v2
|
2020-06-28 13:57:33 +00:00
|
|
|
with:
|
|
|
|
name: upload_url
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Get release upload URL
|
2020-06-28 13:57:33 +00:00
|
|
|
id: upload_url
|
|
|
|
run: |
|
|
|
|
URL=$(cat upload_url.txt)
|
|
|
|
echo "::set-output name=url::${URL}"
|
|
|
|
shell: bash
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Upload Linux/macOS Release
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-') != true
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ steps.upload_url.outputs.url }}
|
|
|
|
asset_path: ./output/sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_x86_64.tar.xz
|
|
|
|
asset_name: sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_x86_64.tar.xz
|
|
|
|
asset_content_type: application/x-xz
|
|
|
|
|
2020-06-29 09:15:24 +00:00
|
|
|
- name: Upload Windows Release
|
2020-06-28 13:57:33 +00:00
|
|
|
if: startsWith(matrix.os, 'windows-')
|
|
|
|
uses: actions/upload-release-asset@v1
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
with:
|
|
|
|
upload_url: ${{ steps.upload_url.outputs.url }}
|
|
|
|
asset_path: ./sftpgo_windows_x86_64.exe
|
|
|
|
asset_name: sftpgo_${{ steps.get_version.outputs.VERSION }}_${{ steps.get_os_name.outputs.OS }}_x86_64.exe
|
|
|
|
asset_content_type: application/x-dosexec
|