Skip to content

Commit

Permalink
ci(publish): update workflow and enable dry run on push to master
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Nov 24, 2024
1 parent 5344011 commit 51d45b3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: publish

on:
# pull_request:
push:
branches:
- master
tags:
- "*"

Expand All @@ -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, '-') }}
Expand Down Expand Up @@ -46,6 +51,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Run sccache-cache
uses: mozilla-actions/[email protected]

- name: Setup extra build tools
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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' || ' ' }}
24 changes: 3 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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/[email protected]
- 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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 51d45b3

Please sign in to comment.