|
@@ -0,0 +1,223 @@
|
|
|
+name: Release Workflow
|
|
|
+
|
|
|
+on:
|
|
|
+ push:
|
|
|
+ tags: 'v*'
|
|
|
+
|
|
|
+env:
|
|
|
+ GOVERSION: 1.14
|
|
|
+
|
|
|
+jobs:
|
|
|
+ create-release:
|
|
|
+ name: Create Release
|
|
|
+ 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
|
|
|
+
|
|
|
+ - name: 'Store release upload URL'
|
|
|
+ uses: actions/upload-artifact@v2
|
|
|
+ with:
|
|
|
+ name: upload_url
|
|
|
+ path: ./upload_url.txt
|
|
|
+
|
|
|
+ upload-src-with-deps:
|
|
|
+ name: Upload sources with dependencies
|
|
|
+ needs: create-release
|
|
|
+ runs-on: ubuntu-latest
|
|
|
+ steps:
|
|
|
+ - uses: actions/checkout@v2
|
|
|
+ - name: Install Go
|
|
|
+ uses: actions/setup-go@v2
|
|
|
+ with:
|
|
|
+ go-version: ${{ env.GOVERSION }}
|
|
|
+
|
|
|
+ - name: Get 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 }}
|
|
|
+
|
|
|
+ - uses: actions/download-artifact@v2
|
|
|
+ with:
|
|
|
+ name: upload_url
|
|
|
+
|
|
|
+ - name: Get upload URL
|
|
|
+ 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
|
|
|
+
|
|
|
+ build:
|
|
|
+ name: Build Release
|
|
|
+ needs: create-release
|
|
|
+ runs-on: ${{ matrix.os }}
|
|
|
+ strategy:
|
|
|
+ matrix:
|
|
|
+ os: [ubuntu-latest, macos-latest, windows-latest]
|
|
|
+
|
|
|
+ steps:
|
|
|
+ - uses: actions/checkout@v2
|
|
|
+ - name: Install Go
|
|
|
+ uses: actions/setup-go@v2
|
|
|
+ with:
|
|
|
+ go-version: ${{ env.GOVERSION }}
|
|
|
+
|
|
|
+ - name: Set up Python
|
|
|
+ if: startsWith(matrix.os, 'windows-')
|
|
|
+ uses: actions/setup-python@v2
|
|
|
+ with:
|
|
|
+ python-version: 3.x
|
|
|
+
|
|
|
+ - name: Build Linux/macOS
|
|
|
+ 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
|
|
|
+
|
|
|
+ - name: Build 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
|
|
|
+ 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
|
|
|
+
|
|
|
+ - name: Get 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 == '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 }}
|
|
|
+
|
|
|
+ - name: Build REST API CLI
|
|
|
+ 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
|
|
|
+
|
|
|
+ - name: Prepare release Linux/macOS
|
|
|
+ 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 }}
|
|
|
+
|
|
|
+ - name: Prepare release Windows
|
|
|
+ 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
|
|
|
+
|
|
|
+ - uses: actions/download-artifact@v2
|
|
|
+ with:
|
|
|
+ name: upload_url
|
|
|
+
|
|
|
+ - name: Get upload URL
|
|
|
+ id: upload_url
|
|
|
+ run: |
|
|
|
+ URL=$(cat upload_url.txt)
|
|
|
+ echo "::set-output name=url::${URL}"
|
|
|
+ shell: bash
|
|
|
+
|
|
|
+ - name: Upload Release Linux/macOS
|
|
|
+ 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
|
|
|
+
|
|
|
+ - name: Upload Release Windows
|
|
|
+ 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
|