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 for header in winscard.h pcsclite.h wintypes.h; do
46 curl -fsSL "https://raw.githubusercontent.com/LudovicRousseau/PCSC/master/src/PCSC/$header" \
47 -o "$PCSC_DIR/include/$header"
48 done
49
50 # Create pkg-config file (headers-only, no library needed for cross-compilation)
51 cat > "$PCSC_DIR/lib/pkgconfig/libpcsclite.pc" << EOF
52 Name: libpcsclite
53 Description: PC/SC Lite
54 Version: 1.9.0
55 Cflags: -I$PCSC_DIR/include
56 EOF
57
58 echo "PKG_CONFIG_PATH=$PCSC_DIR/lib/pkgconfig" >> $GITHUB_ENV
59
60 - name: Get macOS SDK path
61 id: macos_sdk
62 run: echo "path=$(xcrun --show-sdk-path)" >> $GITHUB_OUTPUT
63
64 - name: Run GoReleaser
65 if: steps.tag_version.outputs.new_tag
66 uses: goreleaser/goreleaser-action@v7
67 with:
68 version: latest
69 args: release --clean
70 env:
71 SDK_PATH: ${{ steps.macos_sdk.outputs.path }}
72 GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
73 HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
74
75 snapcraft:
76 runs-on: ${{ matrix.runner }}
77 needs: goreleaser
78 strategy:
79 matrix:
80 include:
81 - arch: amd64
82 runner: ubuntu-latest
83 - arch: arm64
84 runner: ubuntu-24.04-arm
85 steps:
86 - name: Checkout
87 uses: actions/checkout@v6
88 with:
89 fetch-depth: 0
90
91 - name: Install Snapcraft and LXD
92 run: |
93 sudo snap install snapcraft --classic
94 sudo snap install lxd
95 sudo lxd init --auto
96 sudo iptables -P FORWARD ACCEPT
97 sudo usermod -aG lxd $USER
98
99 - name: Build snap
100 run: sg lxd -c 'snapcraft pack --use-lxd --build-for=${{ matrix.arch }}'
101
102 - name: Upload snap
103 env:
104 SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
105 run: snapcraft upload --release=stable *.snap