2021-11-11 16:09:05 +00:00
|
|
|
name: CI
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
pull_request:
|
|
|
|
|
2024-05-12 17:26:00 +00:00
|
|
|
concurrency: ${{ github.ref_name }}
|
|
|
|
|
2021-11-11 16:09:05 +00:00
|
|
|
jobs:
|
|
|
|
tests:
|
|
|
|
runs-on: ubuntu-latest
|
2022-08-11 18:00:25 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-05-09 17:48:06 +00:00
|
|
|
make: ["lint", "unit-test", "integration-test"]
|
2021-11-11 16:09:05 +00:00
|
|
|
steps:
|
2024-03-23 16:44:20 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-11-11 16:09:05 +00:00
|
|
|
|
|
|
|
- name: install go
|
2024-03-23 16:44:20 +00:00
|
|
|
uses: actions/setup-go@v5
|
2021-11-11 16:09:05 +00:00
|
|
|
with:
|
2023-02-16 18:24:16 +00:00
|
|
|
go-version-file: go.mod
|
2021-11-11 16:09:05 +00:00
|
|
|
|
2023-02-16 18:24:16 +00:00
|
|
|
- name: ${{ matrix.make }}
|
2022-08-11 18:00:25 +00:00
|
|
|
run: make ${{ matrix.make }}
|
2021-11-11 16:09:05 +00:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: tests
|
|
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
2021-11-16 18:10:01 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-11-16 18:29:45 +00:00
|
|
|
goosarch: [linux-amd64]
|
2021-11-11 16:09:05 +00:00
|
|
|
steps:
|
2024-03-23 16:44:20 +00:00
|
|
|
- uses: actions/checkout@v4
|
2021-11-16 18:29:45 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-03-18 19:38:18 +00:00
|
|
|
- name: install go
|
2024-03-23 16:44:20 +00:00
|
|
|
uses: actions/setup-go@v5
|
2023-03-18 19:38:18 +00:00
|
|
|
with:
|
|
|
|
go-version-file: go.mod
|
|
|
|
cache: true
|
2021-11-11 16:09:05 +00:00
|
|
|
|
|
|
|
- name: Set env
|
|
|
|
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Sign in to dockerhub
|
|
|
|
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
|
|
|
|
|
|
|
- name: Deploy image
|
2021-11-12 18:01:19 +00:00
|
|
|
run: make docker-push VERSION=$RELEASE_VERSION
|
2021-11-16 18:10:01 +00:00
|
|
|
|
2021-11-16 18:29:45 +00:00
|
|
|
- name: Build
|
|
|
|
run: make build VERSION=$RELEASE_VERSION
|
|
|
|
|
|
|
|
- name: Prepare release
|
|
|
|
run: |
|
2022-03-19 18:08:02 +00:00
|
|
|
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:%h - %s <%an>' --no-merges > changelog.txt
|
2021-11-16 18:29:45 +00:00
|
|
|
tar zcvf whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz whatismyip LICENSE README.md
|
|
|
|
sha256sum whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz > whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz.sha256
|
|
|
|
|
|
|
|
- name: Release
|
2024-03-23 17:05:13 +00:00
|
|
|
uses: softprops/action-gh-release@v2
|
2021-11-16 18:10:01 +00:00
|
|
|
with:
|
2021-11-16 18:29:45 +00:00
|
|
|
body_path: changelog.txt
|
|
|
|
files: |
|
|
|
|
whatismyip-${{env.RELEASE_VERSION}}-${{matrix.goosarch}}.tar.gz
|
|
|
|
whatismyip-${{env.RELEASE_VERSION}}-${{matrix.goosarch}}.tar.gz.sha256
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|