diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 839f8f16..163110f2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,181 +4,148 @@ on: tags: - "v*" -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - jobs: - # Compiles binaries using a bulder matrix - binary_build: - name: Build release binaries + build: + continue-on-error: true + strategy: - fail-fast: false matrix: include: - - target: x86_64-unknown-linux-gnu + - release_for: Linux-GNU-amd64 os: ubuntu-latest - name: scrolls-x86_64-unknown-linux-gnu.tar.gz + target: x86_64-unknown-linux-gnu + args: "--locked --release" + bin: scrolls - - target: x86_64-unknown-linux-musl + - release_for: Linux-GNU-arm64 os: ubuntu-latest - name: scrolls-x86_64-unknown-linux-musl.tar.gz + target: "aarch64-unknown-linux-gnueabihf" + args: "--locked --release" + bin: scrolls - - target: aarch64-unknown-linux-musl - os: ubuntu-latest - name: scrolls-aarch64-unknown-linux-musl.tar.gz - - - target: arm-unknown-linux-musleabihf - os: ubuntu-latest - name: scrolls-arm-unknown-linux-musleabihf.tar.gz + - release_for: Windows-x86_64 + os: windows-latest + target: x86_64-pc-windows-msvc + args: "--locked --release" + bin: scrolls.exe - - target: x86_64-apple-darwin + - release_for: macOS-x86_64 os: macOS-latest - name: scrolls-x86_64-apple-darwin.tar.gz + target: x86_64-apple-darwin + args: "--locked --release" + bin: scrolls - - target: aarch64-apple-darwin + - release_for: macOS-aarch64 os: macOS-latest - name: scrolls-aarch64-apple-darwin.tar.gz - - - target: x86_64-pc-windows-msvc - os: windows-latest - name: scrolls-x86_64-pc-windows-msvc.zip - - - target: aarch64-pc-windows-msvc - os: windows-latest - name: scrolls-aarch64-pc-windows-msvc.zip + target: aarch64-apple-darwin + args: "--locked --release" + bin: scrolls runs-on: ${{ matrix.os }} - continue-on-error: true - steps: - - name: Prev Build | Get Dependencies [Ubuntu] - if: matrix.os == 'ubuntu-latest' - run: | - sudo apt-get install pkg-config libssl-dev - - name: Prev Build | Get Dependencies [MacOS] + steps: + - name: install deps [MacOS] if: matrix.os == 'macOS-latest' run: | brew install openssl@1.1 - - name: Setup | Checkout - uses: actions/checkout@v2.4.0 - - # Cache files between builds - - name: Setup | Cache Cargo - uses: actions/cache@v2.1.7 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: checkout repository + uses: actions/checkout@v3 - - name: Setup | Rust - uses: actions-rs/toolchain@v1.0.7 - with: - toolchain: stable - override: true - profile: minimal - target: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 - - name: Build | Build - uses: actions-rs/cargo@v1.0.3 + - name: build binary + uses: houseabsolute/actions-rust-cross@v0 with: command: build - args: --release --locked --all-features --target ${{ matrix.target }} - use-cross: ${{ matrix.os == 'ubuntu-latest' }} + target: ${{ matrix.target }} + args: ${{ matrix.args }} + strip: true - - name: Post Build | Prepare artifacts [Windows] - if: matrix.os == 'windows-latest' + - name: rename binaries run: | - cd target/${{ matrix.target }}/release - strip scrolls.exe - 7z a ../../../${{ matrix.name }} scrolls.exe - cd - + mv target/${{ matrix.target }}/release/${{ matrix.bin }} ${{ matrix.release_for }}-${{ matrix.bin }} - - name: Post Build | Prepare artifacts [-nix] - if: matrix.os != 'windows-latest' - run: | - cd target/${{ matrix.target }}/release - # TODO: investigate better cross platform stripping - strip scrolls || true - tar czvf ../../../${{ matrix.name }} scrolls - cd - - - - name: Deploy | Upload artifacts - uses: actions/upload-artifact@v2 + - name: upload artifacts + uses: actions/upload-artifact@v3 with: - name: ${{ matrix.name }} - path: ${{ matrix.name }} + name: binaries + path: ${{ matrix.release_for }}-${{ matrix.bin }} - # Creates a GitHub Container package using multi-arch docker builds - container_build: + docker: runs-on: ubuntu-latest + needs: [build] permissions: contents: read packages: write steps: - - name: Checkout + - name: Checkout repository uses: actions/checkout@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@v1 + uses: docker/metadata-action@v4 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ghcr.io/txpipe/scrolls + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=semver,pattern=v{{major}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern=v{{version}} - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io/txpipe username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Download artifacts + uses: actions/download-artifact@v3 + - name: Build and push - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v4 with: context: . - # temporarly removing arm platform until we resolve the ca-certificates issue - #platforms: linux/arm64,linux/amd64 - platforms: linux/amd64 + file: .github/Dockerfile + platforms: linux/arm64,linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - # Create GitHub release with Rust build targets and release notes - github_release: - name: Create GitHub Release - needs: [binary_build, container_build] + release: + needs: [build, docker] + runs-on: ubuntu-latest + steps: - - name: Setup | Checkout - uses: actions/checkout@v2.4.0 + - name: checkout + uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Setup | Go - uses: actions/setup-go@v2 + - name: setup go + uses: actions/setup-go@v4 with: go-version: "1.16" - - name: Setup | Artifacts - uses: actions/download-artifact@v2 - - - name: Setup | Checksums - run: for file in scrolls-*/scrolls-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done + - name: download artifacts + id: "download" + uses: actions/download-artifact@v3 - - name: Setup | Release notes + - name: set release notes run: | go install github.com/git-chglog/git-chglog/cmd/git-chglog@v0.15.0 git-chglog -c .github/chglog/release.yml $(git describe --tags) > RELEASE.md - - name: Build | Publish + - name: create release uses: softprops/action-gh-release@v1 with: - files: scrolls-*/scrolls-* + files: binaries/* body_path: RELEASE.md + draft: true