|
| 1 | +name: 'Release' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'v[0-9]+.[0-9]+.[0-9]+*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + create-release: |
| 11 | + name: create release |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + upload-url: ${{ steps.create_release.outputs.upload_url }} |
| 15 | + version: ${{ steps.get_version.outputs.version }} |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v2 |
| 20 | + |
| 21 | + - name: Get the version |
| 22 | + id: get_version |
| 23 | + run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//} |
| 24 | + |
| 25 | + - name: "Build Changelog" |
| 26 | + id: changelog |
| 27 | + uses: mikepenz/release-changelog-builder-action@v1 |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + |
| 31 | + - name: new release |
| 32 | + uses: actions/create-release@v1 |
| 33 | + id: create_release |
| 34 | + with: |
| 35 | + draft: false |
| 36 | + prerelease: false |
| 37 | + release_name: Policy Tester ${{ steps.get_version.outputs.version }} |
| 38 | + tag_name: ${{ github.ref }} |
| 39 | + body: | |
| 40 | + ${{ steps.changelog.outputs.changelog }} |
| 41 | + env: |
| 42 | + GITHUB_TOKEN: ${{ github.token }} |
| 43 | + |
| 44 | + build: |
| 45 | + name: build tool binaries |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: |
| 48 | + - create-release |
| 49 | + strategy: |
| 50 | + matrix: |
| 51 | + include: |
| 52 | + - {goos: "linux", goarch: "amd64"} |
| 53 | + - {goos: "windows", goarch: "amd64"} |
| 54 | + steps: |
| 55 | + - name: Checkout |
| 56 | + uses: actions/checkout@v2 |
| 57 | + |
| 58 | + - name: Install Go |
| 59 | + uses: actions/setup-go@v2 |
| 60 | + with: |
| 61 | + go-version: '1.17' |
| 62 | + |
| 63 | + - name: Build for ${{ matrix.goos }} |
| 64 | + working-directory: cmd/policyTester |
| 65 | + run: | |
| 66 | + export GOARCH=${{ matrix.goarch }} |
| 67 | + export GOOS=${{ matrix.goos }} |
| 68 | + go build -o bin/ . |
| 69 | + zip -r -j bin/policy-tester.${{ needs.create-release.outputs.version }}.${{ matrix.goos }}-${{ matrix.goarch }}.zip bin/ |
| 70 | + |
| 71 | + - name: upload ${{ matrix.goos }} artifact |
| 72 | + uses: actions/upload-release-asset@v1 |
| 73 | + env: |
| 74 | + GITHUB_TOKEN: ${{ github.token }} |
| 75 | + with: |
| 76 | + upload_url: ${{ needs.create-release.outputs.upload-url }} |
| 77 | + asset_path: cmd/policyTester/bin/policy-tester.${{ needs.create-release.outputs.version }}.${{ matrix.goos }}-${{ matrix.goarch }}.zip |
| 78 | + asset_name: policy-tester.${{ needs.create-release.outputs.version }}.${{ matrix.goos }}-${{ matrix.goarch }}.zip |
| 79 | + asset_content_type: application/zip |
0 commit comments