github/workflow: disable libusb static link for windows build
[fw/openocd] / .github / workflows / snapshot.yml
1 # SPDX-License-Identifier: GPL-2.0-or-later
2
3 # Copyright (C) 2020 by Tarek BOUCHKATI <tarek.bouchkati@gmail.com>
4
5 on: push
6
7 name: OpenOCD Snapshot
8
9 jobs:
10   package:
11     runs-on: [ubuntu-18.04]
12     env:
13       DL_DIR: ../downloads
14       BUILD_DIR: ../build
15     steps:
16       - name: Install needed packages
17         run: |
18           sudo apt-get update
19           sudo apt-get install autotools-dev autoconf automake libtool pkg-config cmake texinfo texlive g++-mingw-w64-i686
20       - name: Checkout Code
21         uses: actions/checkout@v1
22       - run: ./bootstrap
23       - name: Prepare libusb1
24         env:
25           LIBUSB1_VER: 1.0.24
26         run: |
27           mkdir -p $DL_DIR && cd $DL_DIR
28           wget "https://github.com/libusb/libusb/releases/download/v${LIBUSB1_VER}/libusb-${LIBUSB1_VER}.tar.bz2"
29           tar -xjf libusb-${LIBUSB1_VER}.tar.bz2
30           echo "LIBUSB1_SRC=$PWD/libusb-${LIBUSB1_VER}" >> $GITHUB_ENV
31       - name: Prepare hidapi
32         env:
33           HIDAPI_VER: 0.10.1
34         run: |
35           mkdir -p $DL_DIR && cd $DL_DIR
36           wget "https://github.com/libusb/hidapi/archive/hidapi-${HIDAPI_VER}.tar.gz"
37           tar -xzf hidapi-${HIDAPI_VER}.tar.gz
38           cd hidapi-hidapi-${HIDAPI_VER}
39           ./bootstrap
40           echo "HIDAPI_SRC=$PWD" >> $GITHUB_ENV
41       - name: Prepare capstone
42         env:
43           CAPSTONE_VER: 4.0.2
44         run: |
45           mkdir -p $DL_DIR && cd $DL_DIR
46           CAPSTONE_NAME=${CAPSTONE_VER}
47           CAPSTONE_FOLDER=capstone-${CAPSTONE_VER}
48           wget "https://github.com/aquynh/capstone/archive/${CAPSTONE_VER}.tar.gz"
49           tar -xzf ${CAPSTONE_VER}.tar.gz
50           echo "CAPSTONE_SRC=$PWD/capstone-${CAPSTONE_VER}" >> $GITHUB_ENV
51       - name: Package OpenOCD for windows
52         env:
53           MAKE_JOBS: 2
54           HOST: i686-w64-mingw32
55           LIBUSB1_CONFIG: --enable-shared --disable-static
56           HIDAPI_CONFIG: --enable-shared --disable-static --disable-testgui
57           CAPSTONE_CONFIG: "CAPSTONE_BUILD_CORE_ONLY=yes CAPSTONE_STATIC=yes CAPSTONE_SHARED=no"
58         run: |
59           # check if there is tag pointing at HEAD, otherwise take the HEAD SHA-1 as OPENOCD_TAG
60           OPENOCD_TAG="`git tag --points-at HEAD`"
61           [ -z $OPENOCD_TAG ] && OPENOCD_TAG="`git rev-parse --short HEAD`"
62           # check if there is tag pointing at HEAD, if so the release will have the same name as the tag,
63           # otherwise it will be named 'latest'
64           RELEASE_NAME="`git tag --points-at HEAD`"
65           [ -z $RELEASE_NAME ] && RELEASE_NAME="latest"
66           [[ $RELEASE_NAME = "latest" ]] && IS_PRE_RELEASE="true" || IS_PRE_RELEASE="false"
67           # set env and call cross-build.sh
68           export OPENOCD_TAG=$OPENOCD_TAG
69           export OPENOCD_SRC=$PWD
70           export OPENOCD_CONFIG=""
71           mkdir -p $BUILD_DIR &&  cd $BUILD_DIR
72           bash $OPENOCD_SRC/contrib/cross-build.sh $HOST
73           # add missing dlls
74           cd $HOST-root/usr
75           cp `$HOST-gcc --print-file-name=libwinpthread-1.dll` ./bin/
76           cp `$HOST-gcc --print-file-name=libgcc_s_sjlj-1.dll` ./bin/
77           # prepare the artifact
78           ARTIFACT="openocd-${OPENOCD_TAG}-${HOST}.tar.gz"
79           tar -czf $ARTIFACT *
80           echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
81           echo "IS_PRE_RELEASE=$IS_PRE_RELEASE" >> $GITHUB_ENV
82           echo "ARTIFACT_PATH=$PWD/$ARTIFACT" >> $GITHUB_ENV
83       - name: Publish OpenOCD packaged for windows
84         uses: actions/upload-artifact@v2
85         with:
86           path: ${{ env.ARTIFACT_PATH }}
87       - name: Delete 'latest' Release
88         uses: dev-drprasad/delete-tag-and-release@v0.2.0
89         with:
90           delete_release: true
91           tag_name: ${{ env.RELEASE_NAME }}
92         env:
93           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94       - name: Create Release
95         uses: ncipollo/release-action@v1
96         with:
97           tag: ${{ env.RELEASE_NAME }}
98           commit: ${{ github.sha }}
99           draft: false
100           artifacts: ${{ env.ARTIFACT_PATH }}
101           prerelease: ${{ env.IS_PRE_RELEASE }}
102           token: ${{ secrets.GITHUB_TOKEN }}