diff options
| author | Amir Saeid <amir@glgdgt.com> | 2020-06-19 18:42:40 +0100 |
|---|---|---|
| committer | Amir Saeid <amir@glgdgt.com> | 2020-06-19 18:42:40 +0100 |
| commit | dcfd5095b7ed9eac3274556b57931489eecc1d82 (patch) | |
| tree | 927d689b49907410741ebd00df53101e9816828f | |
| parent | a8358262c6b7cefe4a7a9a5e89325777977de7d8 (diff) | |
Add github release workflow
| -rw-r--r-- | .github/workflows/release.yml | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4930448 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,98 @@ +name: release +on: push + +jobs: + create-release: + name: create-release + runs-on: ubuntu-18.04 + steps: + - name: Create artifacts directory + run: mkdir artifacts + + - name: Get the release version from the tag + if: env.SCTD_VERSION == '' + run: | + echo "::set-env name=SCTD_VERSION::${GITHUB_REF#refs/tags/}" + echo "version is: ${{ env.SCTD_VERSION }}" + + - name: Create GitHub release + id: release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.SCTD_VERSION }} + release_name: ${{ env.SCTD_VERSION }} + + - name: Save release upload URL to artifact + run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url + + - name: Save version number to artifact + run: echo "${{ env.SCTD_VERSION }}" > artifacts/release-version + + - name: Upload artifacts + uses: actions/upload-artifact@v1 + with: + name: artifacts + path: artifacts + + build-release: + name: build-release + needs: ['create-release'] + runs-on: ubuntu-18.04 + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install packages + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + libx11-dev \ + libxrandr-dev + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - name: Get release upload URL + uses: actions/download-artifact@v1 + with: + name: artifacts + path: artifacts + + - name: Set release upload URL and release version + shell: bash + run: | + release_upload_url="$(cat artifacts/release-upload-url)" + echo "::set-env name=RELEASE_UPLOAD_URL::$release_upload_url" + echo "release upload url: $RELEASE_UPLOAD_URL" + release_version="$(cat artifacts/release-version)" + echo "::set-env name=RELEASE_VERSION::$release_version" + echo "release version: $RELEASE_VERSION" + + - name: Build release binary + run: cargo build --verbose --release + + - name: Build archive + shell: bash + run: | + staging="sctd-${{ env.RELEASE_VERSION }}" + mkdir "$staging" + cp target/release/sctd "$staging" + cp LICENSE "$staging" + tar czf "$staging.tar.gz" "$staging" + echo "::set-env name=ASSET::$staging.tar.gz" + + - name: Upload release archive + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ env.RELEASE_UPLOAD_URL }} + asset_path: ${{ env.ASSET }} + asset_name: ${{ env.ASSET }} + asset_content_type: application/octet-stream |
