diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..11057adf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,122 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +name: Create Release + +jobs: + create_release: + name: Create Release + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + body: Release ${{ github.ref }} + draft: false + prerelease: false + ubuntu: + needs: create_release + runs-on: ubuntu-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Acquire alan + run: | + wget https://github.com/alantech/alan/releases/latest/download/alan-ubuntu.tar.gz + tar -xzf alan-ubuntu.tar.gz + sudo mv alan /usr/local/bin/alan + + - name: Generate Anycloud tar.gz + run: | + cd cli + cargo build --release + cd ./target/release + tar -czf /tmp/anycloud-ubuntu.tar.gz anycloud + + - name: Upload Anycloud tar.gz + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: /tmp/anycloud-ubuntu.tar.gz + asset_name: anycloud-ubuntu.tar.gz + asset_content_type: application/gzip + + windows: + needs: create_release + runs-on: windows-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Acquire alan + run: | + Invoke-WebRequest -OutFile alan-windows.zip -Uri https://github.com/alantech/alan/releases/latest/download/alan-windows.zip + Expand-Archive -Path alan-windows.zip -DestinationPath C:\windows + + - name: Generate Anycloud zip + run: | + cd cli + cargo build --release + cd .. + Compress-Archive -Path "$(Join-Path (Get-Location).Path '\\cli\\target\\release\\anycloud.exe')" -DestinationPath "$(Join-Path (Get-Location).Path 'anycloud-windows.zip')" + + - name: Upload Anycloud zip + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: ./anycloud-windows.zip + asset_name: anycloud-windows.zip + asset_content_type: application/zip + + macos: + needs: create_release + runs-on: macos-latest + + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + - name: Acquire alan + run: | + brew install gnu-tar + curl -OL https://github.com/alantech/alan/releases/latest/download/alan-macos.tar.gz + gtar -xzf alan-macos.tar.gz + sudo mkdir -p /usr/local/bin + sudo mv alan /usr/local/bin/alan + + - name: Generate Anycloud tar.gz + run: | + cd cli + cargo build --release + cd ./target/release + gtar -czf /tmp/anycloud-macos.tar.gz anycloud + + - name: Upload Anycloud tar.gz + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_release.outputs.upload_url }} + asset_path: /tmp/anycloud-macos.tar.gz + asset_name: anycloud-macos.tar.gz + asset_content_type: application/gzip \ No newline at end of file