|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: macos-14 |
| 17 | + target: aarch64-apple-darwin |
| 18 | + - os: macos-13 |
| 19 | + target: x86_64-apple-darwin |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Install Rust |
| 25 | + uses: dtolnay/rust-toolchain@stable |
| 26 | + with: |
| 27 | + targets: ${{ matrix.target }} |
| 28 | + |
| 29 | + - name: Build |
| 30 | + run: cargo build --release --target ${{ matrix.target }} |
| 31 | + |
| 32 | + - name: Package |
| 33 | + run: | |
| 34 | + cd target/${{ matrix.target }}/release |
| 35 | + tar czf ../../../calendarchy-${{ matrix.target }}.tar.gz calendarchy |
| 36 | + cd ../../.. |
| 37 | +
|
| 38 | + - name: Upload artifact |
| 39 | + uses: actions/upload-artifact@v4 |
| 40 | + with: |
| 41 | + name: calendarchy-${{ matrix.target }} |
| 42 | + path: calendarchy-${{ matrix.target }}.tar.gz |
| 43 | + |
| 44 | + release: |
| 45 | + needs: build |
| 46 | + runs-on: ubuntu-latest |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - name: Download artifacts |
| 51 | + uses: actions/download-artifact@v4 |
| 52 | + with: |
| 53 | + merge-multiple: true |
| 54 | + |
| 55 | + - name: Compute SHA256 hashes |
| 56 | + id: hashes |
| 57 | + run: | |
| 58 | + echo "arm64_sha256=$(sha256sum calendarchy-aarch64-apple-darwin.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" |
| 59 | + echo "x86_64_sha256=$(sha256sum calendarchy-x86_64-apple-darwin.tar.gz | cut -d' ' -f1)" >> "$GITHUB_OUTPUT" |
| 60 | +
|
| 61 | + - name: Create GitHub Release |
| 62 | + uses: softprops/action-gh-release@v2 |
| 63 | + with: |
| 64 | + generate_release_notes: true |
| 65 | + files: | |
| 66 | + calendarchy-aarch64-apple-darwin.tar.gz |
| 67 | + calendarchy-x86_64-apple-darwin.tar.gz |
| 68 | +
|
| 69 | + - name: Update Homebrew formula |
| 70 | + env: |
| 71 | + TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 72 | + run: | |
| 73 | + VERSION="${GITHUB_REF_NAME#v}" |
| 74 | + ARM64_SHA="${{ steps.hashes.outputs.arm64_sha256 }}" |
| 75 | + X86_64_SHA="${{ steps.hashes.outputs.x86_64_sha256 }}" |
| 76 | +
|
| 77 | + cat > /tmp/calendarchy.rb << FORMULA |
| 78 | + class Calendarchy < Formula |
| 79 | + desc "Terminal calendar app for Google Calendar and iCloud" |
| 80 | + homepage "https://github.com/sovanesyan/calendarchy" |
| 81 | + version "${VERSION}" |
| 82 | + license "MIT" |
| 83 | +
|
| 84 | + on_macos do |
| 85 | + on_arm do |
| 86 | + url "https://github.com/sovanesyan/calendarchy/releases/download/v#{version}/calendarchy-aarch64-apple-darwin.tar.gz" |
| 87 | + sha256 "${ARM64_SHA}" |
| 88 | + end |
| 89 | + on_intel do |
| 90 | + url "https://github.com/sovanesyan/calendarchy/releases/download/v#{version}/calendarchy-x86_64-apple-darwin.tar.gz" |
| 91 | + sha256 "${X86_64_SHA}" |
| 92 | + end |
| 93 | + end |
| 94 | +
|
| 95 | + def install |
| 96 | + bin.install "calendarchy" |
| 97 | + end |
| 98 | +
|
| 99 | + test do |
| 100 | + assert_match version.to_s, shell_output("#{bin}/calendarchy --version") |
| 101 | + end |
| 102 | + end |
| 103 | + FORMULA |
| 104 | +
|
| 105 | + # Clone tap repo, update formula, push |
| 106 | + git clone "https://x-access-token:${TAP_TOKEN}@github.com/sovanesyan/homebrew-calendarchy.git" /tmp/tap |
| 107 | + mkdir -p /tmp/tap/Formula |
| 108 | + cp /tmp/calendarchy.rb /tmp/tap/Formula/calendarchy.rb |
| 109 | + cd /tmp/tap |
| 110 | + git config user.name "github-actions[bot]" |
| 111 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 112 | + git add Formula/calendarchy.rb |
| 113 | + git commit -m "Update calendarchy to ${VERSION}" || exit 0 |
| 114 | + git push |
0 commit comments