diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bb90c86..11033e0 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -105,6 +105,26 @@ jobs: with: args: ./... + create-dummy-release: + needs: [ prepare, test, code_scans ] + name: Create empty release + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Get list of the commits since last release + run: | + echo "$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")" > .release_notes + - name: Create empty release + uses: ncipollo/release-action@v1 + with: + bodyFile: ./.release_notes + name: version ${{ needs.prepare.outputs.RELEASE_VERSION }} + token: ${{ secrets.GHCR_TOKEN }} + tag: ${{ needs.prepare.outputs.RELEASE_VERSION }} + prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }} + allowUpdates: true + build: needs: [ prepare, test, code_scans ] name: Docker image build (regular:multiarch) @@ -165,60 +185,76 @@ jobs: # fail-build: false build-binary: - needs: [ prepare, test, code_scans ] + needs: [ prepare, test, code_scans, create-dummy-release ] name: Binary compilation and release runs-on: ubuntu-latest + strategy: + matrix: + # build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 + goos: [linux, windows, darwin] + goarch: ["386", amd64, arm64] + exclude: + - goarch: "386" + goos: darwin + - goarch: arm64 + goos: windows + continue-on-error: [true] steps: - name: Checkout code uses: actions/checkout@v2 with: fetch-depth: 0 - name: Compile binary - uses: thatisuday/go-cross-build@v1.1.0 + uses: wangyoucao577/go-release-action@v1.32 with: - platforms: linux/amd64,darwin/amd64,windows/amd64,linux/arm64,darwin/amd64,darwin/arm64 - name: semver-gen - package: ./ - compress: false - dest: dist + github_token: ${{ secrets.GHCR_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} ldflags: -s -w -X main.PKG_VERSION=${{ needs.prepare.outputs.RELEASE_VERSION }} - - name: Get list of the commits since last release - run: | - echo "$(git log $(git describe --tags --abbrev=0)..HEAD --pretty=format:"%h %s")" > .release_notes - - name: Create Release - id: create_release - uses: marvinpinto/action-automatic-releases@latest - if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - files: dist/semver-gen-* - automatic_release_tag: ${{ needs.prepare.outputs.RELEASE_VERSION }} - title: version ${{ needs.prepare.outputs.RELEASE_VERSION }} - # tag: ${{ needs.prepare.outputs.RELEASE_VERSION }} - # name: ${{ needs.prepare.outputs.RELEASE_VERSION }} - # body_path: .release_notes - # draft: false - prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }} - - name: Delete previous v1 release asset - uses: mknejp/delete-release-assets@v1 - if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} - with: - token: ${{ github.token }} - fail-if-no-assets: false - fail-if-no-release: false - tag: v1 - assets: 'semver-gen-*' - - name: Create Release V1 - id: create_release_global - uses: marvinpinto/action-automatic-releases@latest - if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - files: dist/semver-gen-* - automatic_release_tag: v1 - title: version v1:${{ needs.prepare.outputs.RELEASE_VERSION }} - prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }} + project_path: . + binary_name: semver-gen + asset_name: semver-gen-${{ matrix.goos }}-${{ matrix.goarch }} + release_name: version ${{ needs.prepare.outputs.RELEASE_VERSION }} + release_tag: ${{ needs.prepare.outputs.RELEASE_VERSION }} + compress_assets: false + retry: 10 + overwrite: true + pre_command: export GODEBUG=http2client=0 + + # - name: Create Release + # id: create_release + # uses: marvinpinto/action-automatic-releases@latest + # if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # repo_token: ${{ secrets.GITHUB_TOKEN }} + # files: dist/semver-gen-* + # automatic_release_tag: ${{ needs.prepare.outputs.RELEASE_VERSION }} + # title: version ${{ needs.prepare.outputs.RELEASE_VERSION }} + # # tag: ${{ needs.prepare.outputs.RELEASE_VERSION }} + # # name: ${{ needs.prepare.outputs.RELEASE_VERSION }} + # # body_path: .release_notes + # # draft: false + # prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }} + # - name: Delete previous v1 release asset + # uses: mknejp/delete-release-assets@v1 + # if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} + # with: + # token: ${{ github.token }} + # fail-if-no-assets: false + # fail-if-no-release: false + # tag: v1 + # assets: 'semver-gen-*' + # - name: Create Release V1 + # id: create_release_global + # uses: marvinpinto/action-automatic-releases@latest + # if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # repo_token: ${{ secrets.GITHUB_TOKEN }} + # files: dist/semver-gen-* + # automatic_release_tag: v1 + # title: version v1:${{ needs.prepare.outputs.RELEASE_VERSION }} + # prerelease: ${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/main' }}