diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f897f6d..4f7b8d1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -4,9 +4,9 @@ on: push: branches: - main - tags: - - '**' pull_request: + release: + types: [ published ] jobs: build: @@ -44,6 +44,11 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Install fpm run: sudo gem install fpm @@ -52,12 +57,6 @@ jobs: name: chia-exporter-${{ matrix.GOOS }}-${{ matrix.GOARCH }} path: artifacts - - name: Get tag name - if: startsWith(github.ref, 'refs/tags/') - id: tag-name - run: | - echo "TAG_NAME=$(echo ${{ github.ref }} | cut -d'/' -f 3)" >>$GITHUB_OUTPUT - - name: Generate .deb run: | chmod +x artifacts/chia-exporter @@ -66,7 +65,7 @@ jobs: --output-type deb \ --name chia-exporter \ --architecture ${{ matrix.GOARCH }} \ - --version "${{ steps.tag-name.outputs.TAG_NAME || github.sha }}" \ + --version "${{ env.RELEASE_TAG || github.sha }}" \ --url "https://github.com/Chia-Network/chia-exporter" \ --maintainer "Chia Network Inc " \ --description "Chia metrics Prometheus exporter" \ @@ -84,10 +83,15 @@ jobs: runs-on: ubuntu-latest needs: - installers - if: startsWith(github.ref, 'refs/tags/') + if: github.event.release.published steps: - uses: actions/checkout@v3 + - name: Set Env + uses: Chia-Network/actions/setjobenv@main + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/download-artifact@v3 with: path: artifacts @@ -104,14 +108,6 @@ jobs: zip -r $dir.zip $dir done <<< "$DIRS" - - name: Get tag name - if: startsWith(github.ref, 'refs/tags/') - id: tag-name - run: | - TAG_NAME=$(echo ${{ github.ref }} | cut -d'/' -f 3) - echo "TAG_NAME=$TAG_NAME" >>$GITHUB_ENV - echo "TAG_NAME=$TAG_NAME" >>$GITHUB_OUTPUT - - name: Upload Release Artifacts env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -119,15 +115,16 @@ jobs: FILES=$(find ${{ github.workspace }}/artifacts -type f -name 'chia-exporter*.zip') while IFS= read -r file; do gh release upload \ - $TAG_NAME \ + $RELEASE_TAG \ $file done <<< "$FILES" gh release upload \ - $TAG_NAME \ + $RELEASE_TAG \ artifacts/installer-chia-exporter*/*.deb - name: Trigger apt repo update + if: "!github.event.release.prerelease" run: | - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"release_version":"${{ steps.tag-name.outputs.TAG_NAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/chia-exporter/${{ github.sha }}/start - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"release_version":"${{ steps.tag-name.outputs.TAG_NAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/chia-exporter/${{ github.sha }}/success/deploy + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"release_version":"${{ env.RELEASE_TAG }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/chia-exporter/${{ github.sha }}/start + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"release_version":"${{ env.RELEASE_TAG }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/chia-exporter/${{ github.sha }}/success/deploy