diff options
Diffstat (limited to '.github/workflows/release.yml')
| -rw-r--r-- | .github/workflows/release.yml | 112 |
1 files changed, 53 insertions, 59 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a887f70..f63fdf0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,50 +4,58 @@ on: tags: - '[0-9]+.[0-9]+.[0-9]+' +permissions: + contents: write + jobs: create-release: name: create-release - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest + outputs: + sctd_version: ${{ env.SCTD_VERSION }} steps: - - name: Create artifacts directory - run: mkdir artifacts - + - uses: actions/checkout@v4 - name: Get the release version from the tag - if: env.SCTD_VERSION == '' + shell: bash + run: echo "SCTD_VERSION=${{ github.ref_name }}" >> $GITHUB_ENV + - name: Show the version run: | - echo "::set-env name=SCTD_VERSION::${GITHUB_REF#refs/tags/}" - echo "version is: ${{ env.SCTD_VERSION }}" - + echo "version is: $SCTD_VERSION" + - name: Check that tag version and Cargo.toml version are the same + shell: bash + run: | + if ! grep -q "version = \"$SCTD_VERSION\"" Cargo.toml; then + echo "version does not match Cargo.toml" >&2 + exit 1 + fi - 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 + run: gh release create ${{ env.SCTD_VERSION }} --draft --verify-tag --title ${{ env.SCTD_VERSION }} build-release: name: build-release needs: ['create-release'] - runs-on: ubuntu-18.04 + runs-on: ${{ matrix.os }} + strategy: + matrix: + build: [linux, macos] + include: + - build: linux + os: ubuntu-latest + rust: stable + target: x86_64-unknown-linux-gnu + - build: macos + os: macos-latest + rust: stable + target: x86_64-apple-darwin + steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Install packages + - name: Install packages (Linux) + if: matrix.build == 'linux' run: | sudo apt-get update sudo apt-get install -y --no-install-recommends \ @@ -55,47 +63,33 @@ jobs: 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 + uses: dtolnay/rust-toolchain@master 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" + toolchain: ${{ matrix.rust }} + target: ${{ matrix.target }} - name: Build release binary - run: cargo build --verbose --release + run: cargo build --verbose --release --target ${{ matrix.target }} + + - name: Strip release binary (linux and macos) + if: matrix.build == 'linux' || matrix.build == 'macos' + run: strip "target/${{ matrix.target }}/release/sctd" - name: Build archive shell: bash run: | - staging="sctd-${{ env.RELEASE_VERSION }}" + staging="sctd-${{ needs.create-release.outputs.sctd_version }}-${{ matrix.target }}" mkdir -p "$staging" - cp target/release/sctd "$staging" - cp LICENSE "$staging" + + cp "target/${{ matrix.target }}/release/sctd" "$staging/" + cp README.md LICENSE "$staging/" + tar czf "$staging.tar.gz" "$staging" - echo "::set-env name=ASSET::$staging.tar.gz" + shasum -a 256 "$staging.tar.gz" > "$staging.tar.gz.sha256" + echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV + echo "ASSET_SUM=$staging.tar.gz.sha256" >> $GITHUB_ENV - 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 + run: gh release upload ${{ needs.create-release.outputs.sctd_version }} ${{ env.ASSET }} ${{ env.ASSET_SUM }} |
