diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..2732fe3 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,49 @@ +--- +name: Build Action +on: + pull_request: + branches: + - master + release: + types: + - published + push: + branches: + - master + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Ensure Go Version + uses: actions/setup-go@v3 + with: + go-version: '1.20' + + - name: Lint + uses: golangci/golangci-lint-action@v3 + with: + args: --build-tags integration -p bugs -p unused --timeout=3m + + - name: Make tag + run: | + [ "${GITHUB_EVENT_NAME}" == 'pull_request' ] && echo "GITHUB_TAG_NAME=$(echo $GITHUB_REF | awk -F / '{print $3}')-${GITHUB_HEAD_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'release' ] && echo "GITHUB_TAG_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV || true + [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "GITHUB_TAG_NAME=latest" >> $GITHUB_ENV || true + + - name: Build project + run: | + make + + - name: Upload Release Asset + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + files: | + bin/nftables-exporter* + if: ${{ github.event_name == 'release' }} diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml deleted file mode 100644 index b573d10..0000000 --- a/.github/workflows/master.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: master - -on: - push: - branches: - - master - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Set up Go 1.20 - uses: actions/setup-go@v3 - with: - go-version: '1.20.x' - - name: Lint - uses: golangci/golangci-lint-action@v3 - with: - args: -p bugs -p unused - - name: Build project - run: | - make - - - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index 31ebc9a..0000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: master - -on: - pull_request: - branches: - - master - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Set up Go 1.20 - uses: actions/setup-go@v3 - with: - go-version: '1.20.x' - - name: Lint - uses: golangci/golangci-lint-action@v3 - with: - args: -p bugs -p unused - - name: Build project - run: | - make diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml new file mode 100644 index 0000000..da232f3 --- /dev/null +++ b/.github/workflows/release-drafter.yaml @@ -0,0 +1,15 @@ +--- +name: Release Drafter Action + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index b42c907..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: release - -on: - release: - types: - - published - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Set up Go 1.20 - uses: actions/setup-go@v3 - with: - go-version: '1.20.x' - - - name: Build project - run: | - export GITHUB_TAG_NAME=${GITHUB_REF##*/} - make release - - - name: Upload Release Asset - uses: softprops/action-gh-release@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - files: | - bin/nftables-exporter* - if: ${{ github.event_name == 'release' }}