From 51d45b36cfe9267b920271023185bc01af755ae6 Mon Sep 17 00:00:00 2001 From: rami3l Date: Sun, 24 Nov 2024 10:29:41 +0800 Subject: [PATCH] ci(publish): update workflow and enable dry run on push to `master` --- .github/workflows/publish.yml | 23 ++++++++++++++++------- .github/workflows/test.yml | 24 +++--------------------- .goreleaser.yml | 9 ++++++--- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cf953019d0..bfe0186ccd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,7 +1,10 @@ name: publish on: + # pull_request: push: + branches: + - master tags: - "*" @@ -17,8 +20,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - name: Create release + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') uses: softprops/action-gh-release@v2 with: prerelease: ${{ contains(github.ref, '-') }} @@ -46,6 +51,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.6 + - name: Setup extra build tools if: matrix.target == 'aarch64-unknown-linux-musl' run: | @@ -74,7 +82,7 @@ jobs: needs: [build-release] runs-on: ubuntu-latest container: - # Note: It is also possible to install `choco` directly: + # NOTE: It is also possible to install `choco` directly: # https://github.com/JetBrains/qodana-cli/blob/29134e654dc4878e0587f02338c5101bce327560/.github/workflows/release.yml#L19-L27 image: chocolatey/choco:latest-linux steps: @@ -87,7 +95,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@v5 with: - go-version: ">=1.20.0" + go-version: stable # https://github.com/vercel/turbo/blob/ea934d13038361c24a1f71cad3b490d6c0936f37/.github/workflows/turborepo-release.yml#L306-L309 - name: Download artifacts @@ -104,11 +112,11 @@ jobs: chown -R $(id -u):$(id -g) $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-x86_64-pc-windows-msvc target/gh-artifacts/pacaptr_windows_amd64 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-x86_64-apple-darwin target/gh-artifacts/pacaptr_darwin_amd64 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-x86_64-unknown-linux-musl target/gh-artifacts/pacaptr_linux_amd64 mv -f target/gh-artifacts/pacaptr-aarch64-unknown-linux-musl target/gh-artifacts/pacaptr_linux_arm64 echo '=======' ls -laR target/gh-artifacts @@ -119,7 +127,7 @@ jobs: with: distribution: goreleaser version: latest - args: release --debug + args: release --clean --verbose ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') && ' ' || '--snapshot --skip=publish' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} @@ -134,5 +142,6 @@ jobs: # https://github.com/goreleaser/goreleaser/blob/2a3009757a8996cdcf2a77deb0e5fa413d1f2660/internal/pipe/chocolatey/chocolatey.go#L201-L208 # https://stackoverflow.com/a/75835172 - name: Publish app on Chocolatey + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') run: | - choco push dist/*.nupkg --source https://push.chocolatey.org --api-key ${{ secrets.CHOCO_API_KEY }} --verbose ${{ contains(github.ref, '-') && '--noop' || '' }} + choco push dist/*.nupkg --source https://push.chocolatey.org --api-key ${{ secrets.CHOCO_API_KEY }} --verbose ${{ contains(github.ref, '-') && '--noop' || ' ' }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 22aef1ae4b..7fded9ea5d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,8 +28,8 @@ jobs: concurrent_skipping: same_content do_not_skip: '["pull_request"]' - build: - name: build (${{ matrix.os }} native + ${{ matrix.target2 }}) + lint: + name: lint (${{ matrix.os }}) needs: skip-check if: ${{ needs.skip-check.outputs.should_skip != 'true' }} runs-on: ${{ matrix.os }} @@ -38,28 +38,15 @@ jobs: matrix: include: - os: windows-latest - # target: x86_64-pc-windows-msvc - target2: aarch64-pc-windows-msvc - os: macos-latest - # target: aarch64-apple-darwin - target2: x86_64-apple-darwin - os: ubuntu-latest - # target: x86_64-unknown-linux-musl - target2: aarch64-unknown-linux-musl steps: - uses: actions/checkout@v4 - - name: Setup extra build tools - if: matrix.target2 == 'aarch64-unknown-linux-musl' - run: | - sudo apt-get update - sudo apt-get install -y gcc-aarch64-linux-gnu - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.6 - name: Setup Rust if: ${{ steps.cache_build.outputs.cache-hit != 'true' }} uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target2 }} - name: Setup `cargo-binstall` and `taplo` uses: taiki-e/install-action@v2 with: @@ -76,11 +63,6 @@ jobs: - name: Lint Rust run: | cargo clippy --all-targets --all-features - - name: Build - if: ${{ steps.cache_build.outputs.cache-hit != 'true' }} - run: | - cargo build --verbose --locked - cargo build --verbose --locked --target=${{ matrix.target2 }} choco-test: runs-on: windows-latest @@ -399,7 +381,7 @@ jobs: # https://github.com/PyO3/pyo3/blob/42601f3af94242b017402b763a495798a92da8f8/.github/workflows/ci.yml#L452-L472 conclusion: needs: - - build + - lint - choco-test - scoop-winget-test - brew-test diff --git a/.goreleaser.yml b/.goreleaser.yml index 45edbda626..864bfad096 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,7 @@ -# This is an example .goreleaser.yml file with some sensible defaults. -# Make sure to check the documentation at https://goreleaser.com +# Check the documentation at https://goreleaser.com # Adapted from https://github.com/LGUG2Z/komorebi/blob/e240bc770619fa7c1f311b8a376551f2dde8a2d7/.goreleaser.yml +version: 2 project_name: pacaptr before: @@ -21,7 +21,7 @@ builds: - amd64 hooks: # Actually override the release binary. - post: bash -c 'mv -f target/gh-artifacts/pacaptr_{{ .Target }}/{{ .Name }} {{ .Path }}' + post: bash -c 'mv -f target/gh-artifacts/{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}/{{ .Name }} {{ .Path }}' universal_binaries: - replace: true @@ -59,6 +59,9 @@ brews: description: Pacman-like syntax wrapper for many package managers. license: GPL-3.0-only + directory: Formula + commit_msg_template: "feat(formula): add `{{ .ProjectName }}` {{ .Tag }}" + custom_block: | head "https://github.com/rami3l/pacaptr.git"