diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7568c7ce..db47de6c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,11 +29,6 @@ jobs: name: Build runs-on: macos-latest needs: [get_version, test] - strategy: - fail-fast: false - matrix: - os: [ darwin, linux, windows ] - arch: [ arm64, amd64 ] steps: - uses: actions/checkout@v2 - uses: actions/setup-go@v3 @@ -41,55 +36,149 @@ jobs: go-version: '1.19.3' cache: true - run: ./tools/version.sh - - run: go build -o ipatool-${{ needs.get_version.outputs.version }}-${GOOS//darwin/macos}-$GOARCH + - run: go build -o ipatool-${{ needs.get_version.outputs.version }}-windows-arm64 + env: + GOOS: windows + GOARCH: arm64 + - run: go build -o ipatool-${{ needs.get_version.outputs.version }}-windows-amd64 + env: + GOOS: windows + GOARCH: amd64 + - run: go build -o ipatool-${{ needs.get_version.outputs.version }}-linux-arm64 env: - GOOS: ${{ matrix.os }} - GOARCH: ${{ matrix.arch }} + GOOS: linux + GOARCH: arm64 + - run: go build -o ipatool-${{ needs.get_version.outputs.version }}-linux-amd64 + env: + GOOS: linux + GOARCH: amd64 + - run: go build -o ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 + env: + GOOS: darwin + GOARCH: arm64 CGO_CFLAGS: -mmacosx-version-min=10.15 CGO_LDFLAGS: -mmacosx-version-min=10.15 - - id: output - run: echo ::set-output name=file::ipatool-${{ needs.get_version.outputs.version }}-${GOOS//darwin/macos}-$GOARCH + CGO_ENABLED: 1 + - run: go build -o ipatool-${{ needs.get_version.outputs.version }}-macos-amd64 env: - GOOS: ${{ matrix.os }} - GOARCH: ${{ matrix.arch }} + GOOS: darwin + GOARCH: amd64 + CGO_CFLAGS: -mmacosx-version-min=10.15 + CGO_LDFLAGS: -mmacosx-version-min=10.15 + CGO_ENABLED: 1 + - uses: actions/upload-artifact@v2 + with: + name: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64 + path: ipatool-${{ needs.get_version.outputs.version }}-windows-arm64 + if-no-files-found: error + - uses: actions/upload-artifact@v2 + with: + name: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64 + path: ipatool-${{ needs.get_version.outputs.version }}-windows-amd64 + if-no-files-found: error + - uses: actions/upload-artifact@v2 + with: + name: ipatool-${{ needs.get_version.outputs.version }}-linux-arm64 + path: ipatool-${{ needs.get_version.outputs.version }}-linux-arm64 + if-no-files-found: error + - uses: actions/upload-artifact@v2 + with: + name: ipatool-${{ needs.get_version.outputs.version }}-linux-amd64 + path: ipatool-${{ needs.get_version.outputs.version }}-linux-amd64 + if-no-files-found: error - uses: actions/upload-artifact@v2 with: - name: ${{ steps.output.outputs.file }} - path: ${{ steps.output.outputs.file }} + name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 + path: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 if-no-files-found: error - release: - name: Release + - uses: actions/upload-artifact@v2 + with: + name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64 + path: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64 + if-no-files-found: error + release_windows_linux: + name: Release (Windows & Linux) runs-on: ubuntu-latest needs: [get_version, build] strategy: fail-fast: false matrix: - os: [ darwin, linux, windows ] + os: [ linux, windows ] arch: [ arm64, amd64 ] steps: - uses: actions/checkout@v2 - - id: output - run: echo ::set-output name=file::ipatool-${{ needs.get_version.outputs.version }}-${GOOS//darwin/macos}-$GOARCH - env: - GOOS: ${{ matrix.os }} - GOARCH: ${{ matrix.arch }} - uses: actions/download-artifact@v2 with: - name: ${{ steps.output.outputs.file }} + name: ipatool-${{ needs.get_version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }} path: bin - - run: tar -czvf ${{ steps.output.outputs.file }}.tar.gz bin/${{ steps.output.outputs.file }} - - run: ./tools/sha256sum.sh ${{ steps.output.outputs.file }}.tar.gz > ${{ steps.output.outputs.file }}.tar.gz.sha256sum + - run: tar -czvf $BIN.tar.gz bin/$BIN + env: + BIN: ipatool-${{ needs.get_version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }} - uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ steps.output.outputs.file }}.tar.gz - asset_name: ${{ steps.output.outputs.file }}.tar.gz + file: ipatool-${{ needs.get_version.outputs.version }}-${{ matrix.os }}-${{ matrix.arch }}.* tag: ${{ github.ref }} overwrite: false + file_glob: true + release_macos: + name: Release (macOS) + runs-on: ubuntu-latest + needs: [get_version, build, release_windows_linux] + steps: + - uses: actions/checkout@v2 + - uses: actions/download-artifact@v2 + with: + name: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 + path: bin + - run: tar -czvf $BIN.tar.gz bin/$BIN && rm -rf bin/ + env: + BIN: ipatool-${{ needs.get_version.outputs.version }}-macos-arm64 + - uses: actions/download-artifact@v2 + with: + name: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64 + path: bin + - run: tar -czvf $BIN.tar.gz bin/$BIN && rm -rf bin/ + env: + BIN: ipatool-${{ needs.get_version.outputs.version }}-macos-amd64 + - id: sha256 + run: | + SHA256_ARM64=$(./tools/sha256sum.sh ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz) + SHA256_AMD64=$(./tools/sha256sum.sh ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz) + echo $SHA256_ARM64 > ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz.sha256sum + echo $SHA256_AMD64 > ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz.sha256sum + echo ::set-output name=sha256_arm64::$SHA256_ARM64 + echo ::set-output name=sha256_amd64::$SHA256_AMD64 - uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: ${{ steps.output.outputs.file }}.tar.gz.sha256sum - asset_name: ${{ steps.output.outputs.file }}.tar.gz.sha256sum + file: ipatool-${{ needs.get_version.outputs.version }}-macos-* tag: ${{ github.ref }} overwrite: false + file_glob: true + outputs: + sha256_arm64: ${{ steps.sha256.outputs.sha256_arm64 }} + sha256_amd64: ${{ steps.sha256.outputs.sha256_amd64 }} + update_cask: + name: Update cask + runs-on: ubuntu-latest + needs: [get_version, release_macos] + steps: + - uses: actions/checkout@v2 + with: + repository: ${{ secrets.HOMEBREW_REPO }} + ref: main + token: ${{ secrets.GH_TOKEN }} + - run: | + sed -i "3s/.*/ sha256 \"${{ needs.release_macos.outputs.sha256_arm64 }}\"/" Casks/ipatool.rb + sed -i "4s/.*/ url \"https:\/\/github.com\/majd\/ipatool\/releases\/download\/v${{ needs.get_version.outputs.version }}\/ipatool-${{ needs.get_version.outputs.version }}-macos-arm64.tar.gz\"/" Casks/ipatool.rb + sed -i "5s/.*/ binary \"bin\/ipatool-${{ needs.get_version.outputs.version }}-macos-arm64\", target: \"ipatool\"/" Casks/ipatool.rb + sed -i "7s/.*/ sha256 \"${{ needs.release_macos.outputs.sha256_amd64 }}\"/" Casks/ipatool.rb + sed -i "8s/.*/ url \"https:\/\/github.com\/majd\/ipatool\/releases\/download\/v${{ needs.get_version.outputs.version }}\/ipatool-${{ needs.get_version.outputs.version }}-macos-amd64.tar.gz\"/" Casks/ipatool.rb + sed -i "9s/.*/ binary \"bin\/ipatool-${{ needs.get_version.outputs.version }}-macos-amd64\", target: \"ipatool\"/" Casks/ipatool.rb + sed -i "12s/.*/ version \"${{ needs.get_version.outputs.version }}\"/" Casks/ipatool.rb + git config --local user.name ${{ secrets.GH_NAME }} + git config --local user.email ${{ secrets.GH_EMAIL }} + git add Casks/ipatool.rb + git commit -m "Update ipatool to v${{ needs.get_version.outputs.version }}" + git push "https://${{ secrets.GH_TOKEN }}@github.com/${{ secrets.HOMEBREW_REPO }}.git" --set-upstream "main" \ No newline at end of file