|
| 1 | +name: build |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - 'main' |
| 12 | + tags: |
| 13 | + - 'v*' |
| 14 | + pull_request: |
| 15 | + |
| 16 | +env: |
| 17 | + GO_VERSION: 1.23.0 |
| 18 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + runs-on: ubuntu-22.04 |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + - name: Build |
| 29 | + run: | |
| 30 | + make build |
| 31 | + - name: Upload artifacts |
| 32 | + uses: actions/upload-artifact@v4 |
| 33 | + with: |
| 34 | + name: gateway-oauth2 |
| 35 | + path: gateway-oauth2-* |
| 36 | + if-no-files-found: error |
| 37 | + |
| 38 | + windows_build: |
| 39 | + runs-on: windows-latest |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + fetch-depth: 0 |
| 45 | + - name: Set up Go |
| 46 | + uses: actions/setup-go@v5 |
| 47 | + with: |
| 48 | + go-version: ${{ env.GO_VERSION }} |
| 49 | + - name: Build |
| 50 | + run: | |
| 51 | + make build-windows |
| 52 | + - name: Upload Windows Artifact |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + with: |
| 55 | + name: gateway-oauth2-windows |
| 56 | + path: gateway-oauth2-*.exe |
| 57 | + if-no-files-found: error |
| 58 | + |
| 59 | + create_release: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + needs: [ build, windows_build ] |
| 62 | + if: startsWith(github.ref, 'refs/tags/v') |
| 63 | + steps: |
| 64 | + - run: sleep 10 |
| 65 | + - name: Download all artifacts |
| 66 | + uses: actions/download-artifact@v4 |
| 67 | + - run: ls -lR |
| 68 | + - run: | |
| 69 | + (cd gateway-oauth2 && sha256sum -b *) > checksums.txt |
| 70 | + (cd gateway-oauth2-windows && sha256sum -b *) >> checksums.txt |
| 71 | + - name: install gh CLI |
| 72 | + run: | |
| 73 | + # Command taken from here: https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt |
| 74 | + (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \ |
| 75 | + && sudo mkdir -p -m 755 /etc/apt/keyrings \ |
| 76 | + && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ |
| 77 | + && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ |
| 78 | + && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ |
| 79 | + && sudo apt update \ |
| 80 | + && sudo apt install gh -y |
| 81 | + - name: attach artifacts to release |
| 82 | + run: | |
| 83 | + RELEASE_NAME=${{ github.ref_name }} |
| 84 | + gh release upload $RELEASE_NAME gateway-oauth2/* --repo ${{ github.repository }} --clobber |
| 85 | + gh release upload $RELEASE_NAME gateway-oauth2-windows/* --repo ${{ github.repository }} --clobber |
| 86 | + gh release upload $RELEASE_NAME checksums.txt --repo ${{ github.repository }} --clobber |
0 commit comments