From fc65eb25b880b7d4cfd6d9405b9b66925832a0cd Mon Sep 17 00:00:00 2001 From: Eldwan Brianne Date: Mon, 2 Nov 2020 19:47:19 +0100 Subject: [PATCH] Added workflow --- .github/workflows/tag.yml | 84 +++++++++++++++++++++++++++++++++++++++ .gitignore | 6 +-- 2 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/tag.yml diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..e5eeb5a --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,84 @@ +name: Build/Push (tag) + +on: + push: + tags: + - '*' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + go_version: [ '1.12', '1.13', '1.14' ] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go_version }} + - run: go get -t -v ./... + + release: + runs-on: ubuntu-latest + needs: test + steps: + - name: Create release + id: create + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: false + outputs: + upload_url: ${{ steps.create.outputs.upload_url }} + + upload: + runs-on: ubuntu-latest + needs: release + strategy: + matrix: + include: + - os: linux + arch: 386 + - os: linux + arch: amd64 + - os: linux + arch: arm + - os: darwin + arch: 386 + - os: darwin + arch: amd64 + - os: windows + arch: 386 + extension: '.exe' + - os: windows + arch: amd64 + extension: '.exe' + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.14 + + - name: Download go dependencies + run: go get -t -v ./... + + - name: Install mitchellh/gox to create platform specific releases + run: go install github.com/mitchellh/gox + + - name: Create release + run: gox -ldflags "-s -w" -os="${{ matrix.os }}" -arch="${{ matrix.arch }}" -output="adguard_exporter-{{.OS}}-{{.Arch}}" -verbose ./... + + - name: Upload release assets + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.release.outputs.upload_url }}${{ matrix.extension }} + asset_path: ./adguard_exporter-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.extension }} + asset_name: adguard_exporter-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.extension }} + asset_content_type: application/octet-stream diff --git a/.gitignore b/.gitignore index 05068ec..47419e2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ vendor -bin -tmp -.vscode -report.xml debug -.idea/ adguard_exporter +.git/