1name: Release
2
3on:
4 workflow_dispatch:
5
6permissions:
7 contents: write # to create releases, tags and upload assets
8 pull-requests: read # to read pull request titles and labels for changelog
9 id-token: write # to sign the release
10
11jobs:
12 goreleaser:
13 runs-on: macos-latest
14 steps:
15 - name: Checkout
16 uses: actions/checkout@v6
17 with:
18 fetch-depth: 0
19
20 - name: Set up Go
21 uses: actions/setup-go@v6
22 with:
23 go-version: "1.26.1"
24
25 - name: Set up Zig
26 uses: goto-bus-stop/setup-zig@v2
27
28 - name: Bump version and push tag
29 id: tag_version
30 uses: mathieudutour/github-tag-action@v6.2
31 with:
32 github_token: ${{ secrets.GITHUB_TOKEN }}
33
34 - name: Fetch the new tag
35 run: git fetch --tags
36 env:
37 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
39 - name: Set up libpcsclite for Linux cross-compilation
40 run: |
41 PCSC_DIR="$RUNNER_TEMP/pcsclite"
42 mkdir -p "$PCSC_DIR/include" "$PCSC_DIR/lib/pkgconfig"
43
44 # Download pcsc-lite headers from upstream
45 PCSC_URL="https://raw.githubusercontent.com/LudovicRousseau/PCSC/master/src/PCSC"
46 for header in winscard.h wintypes.h; do
47 curl -fsSL "$PCSC_URL/$header" -o "$PCSC_DIR/include/$header"
48 done
49 # pcsclite.h is generated from pcsclite.h.in — download and substitute the version placeholder
50 curl -fsSL "$PCSC_URL/pcsclite.h.in" -o "$PCSC_DIR/include/pcsclite.h"
51 sed -i '' 's/@VERSION@/1.9.0/' "$PCSC_DIR/include/pcsclite.h"
52
53 # Create pkg-config file (headers-only, no library needed for cross-compilation)
54 cat > "$PCSC_DIR/lib/pkgconfig/libpcsclite.pc" << EOF
55 Name: libpcsclite
56 Description: PC/SC Lite
57 Version: 1.9.0
58 Cflags: -I$PCSC_DIR/include
59 EOF
60
61 echo "PKG_CONFIG_PATH=$PCSC_DIR/lib/pkgconfig" >> $GITHUB_ENV
62
63 - name: Get macOS SDK path
64 id: macos_sdk
65 run: echo "path=$(xcrun --show-sdk-path)" >> $GITHUB_OUTPUT
66
67 - name: Run GoReleaser
68 if: steps.tag_version.outputs.new_tag
69 uses: goreleaser/goreleaser-action@v7
70 with:
71 version: latest
72 args: release --clean
73 env:
74 SDK_PATH: ${{ steps.macos_sdk.outputs.path }}
75 GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
76 HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
77
78 snapcraft:
79 runs-on: ${{ matrix.runner }}
80 needs: goreleaser
81 strategy:
82 matrix:
83 include:
84 - arch: amd64
85 runner: ubuntu-latest
86 - arch: arm64
87 runner: ubuntu-24.04-arm
88 steps:
89 - name: Checkout
90 uses: actions/checkout@v6
91 with:
92 fetch-depth: 0
93
94 - name: Install Snapcraft and LXD
95 run: |
96 sudo snap install snapcraft --classic
97 sudo snap install lxd
98 sudo lxd init --auto
99 sudo iptables -P FORWARD ACCEPT
100 sudo usermod -aG lxd $USER
101
102 - name: Build snap
103 run: sg lxd -c 'snapcraft pack --use-lxd --build-for=${{ matrix.arch }}'
104
105 - name: Upload snap
106 env:
107 SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
108 run: snapcraft upload --release=stable *.snap