Skip to content

ci(publish): try to use chocolatey/choco:latest-linux for goreleaser #136

ci(publish): try to use chocolatey/choco:latest-linux for goreleaser

ci(publish): try to use chocolatey/choco:latest-linux for goreleaser #136

Workflow file for this run

name: publish
on:
push:
tags:
- "*"
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs:
create-release:
name: Create GitHub release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create release
uses: softprops/action-gh-release@v1
with:
prerelease: ${{ contains(github.ref, '-') }}
build-release:
name: Build release binaries for ${{ matrix.target }}
needs: [create-release]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: windows-latest
target: aarch64-pc-windows-msvc
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
steps:
- uses: actions/checkout@v3
- name: Setup extra build tools
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: |
cargo build --verbose --bin=pacaptr --release --locked --target=${{ matrix.target }}
# https://github.com/vercel/turbo/blob/ea934d13038361c24a1f71cad3b490d6c0936f37/.github/workflows/turborepo-release.yml#L268-L272
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: pacaptr-${{ matrix.target }}
path: target/${{ matrix.target }}/release/pacaptr*
retention-days: 1
publish:
name: Publish via GoReleaser
needs: [build-release]
runs-on: ubuntu-latest
container:
image: chocolatey/choco:latest-linux
steps:
- uses: actions/checkout@v3
- name: Setup build essential
run: |
apt-get update && apt-get install -y curl build-essential
- name: Setup Golang
uses: actions/setup-go@v4
with:
go-version: ">=1.20.0"
# https://github.com/vercel/turbo/blob/ea934d13038361c24a1f71cad3b490d6c0936f37/.github/workflows/turborepo-release.yml#L306-L309
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: target/gh-artifacts
# Here we use `mv` to map Rust targets to Golang ones.
# https://github.com/vercel/turbo/blob/ea934d13038361c24a1f71cad3b490d6c0936f37/.github/workflows/turborepo-release.yml#L313-L318
- name: Modify and inspect artifacts
shell: bash
run: |
echo $PWD
chmod -R 744 target/gh-artifacts
ls -laR target/gh-artifacts
mv -f target/gh-artifacts/pacaptr-x86_64-pc-windows-msvc target/gh-artifacts/pacaptr_windows_amd64_v1
mv -f target/gh-artifacts/pacaptr-aarch64-pc-windows-msvc target/gh-artifacts/pacaptr_windows_arm64
mv -f target/gh-artifacts/pacaptr-x86_64-apple-darwin target/gh-artifacts/pacaptr_darwin_amd64_v1
mv -f target/gh-artifacts/pacaptr-aarch64-apple-darwin target/gh-artifacts/pacaptr_darwin_arm64
mv -f target/gh-artifacts/pacaptr-x86_64-unknown-linux-musl target/gh-artifacts/pacaptr_linux_amd64_v1
mv -f target/gh-artifacts/pacaptr-aarch64-unknown-linux-musl target/gh-artifacts/pacaptr_linux_arm64
echo '======='
ls -laR target/gh-artifacts
# https://goreleaser.com/ci/actions/?h=github+act#usage
- name: Publish via GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean --debug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}