|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - github-actions |
| 7 | +# tags: |
| 8 | +# - '[0-9]+.*' |
| 9 | + |
| 10 | +env: |
| 11 | + YS_RELEASE_VERBOSE: 1 |
| 12 | + |
| 13 | +jobs: |
| 14 | + create-release: |
| 15 | + name: Create GitHub Release |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + release_id: ${{ steps.create_release.outputs.id }} |
| 19 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Get version from tag |
| 25 | + id: get_version |
| 26 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 27 | + |
| 28 | + - name: Generate release notes |
| 29 | + id: release_notes |
| 30 | + run: | |
| 31 | + # Extract release notes from Changes file |
| 32 | + if [ -f Changes ]; then |
| 33 | + # Get the section for this version from Changes file |
| 34 | + awk '/^'"${{ steps.get_version.outputs.VERSION }}"':/ {flag=1; next} /^[0-9]+\.[0-9]+\.[0-9]+:/ {flag=0} flag' Changes > release-notes.txt |
| 35 | + else |
| 36 | + echo "Release ${{ steps.get_version.outputs.VERSION }}" > release-notes.txt |
| 37 | + fi |
| 38 | +
|
| 39 | + # Add footer |
| 40 | + cat common/release.md >> release-notes.txt || true |
| 41 | +
|
| 42 | + - name: Create Release |
| 43 | + id: create_release |
| 44 | + uses: actions/github-script@v7 |
| 45 | + with: |
| 46 | + script: | |
| 47 | + const fs = require('fs'); |
| 48 | + const releaseNotes = fs.readFileSync('release-notes.txt', 'utf8'); |
| 49 | +
|
| 50 | + const release = await github.rest.repos.createRelease({ |
| 51 | + owner: context.repo.owner, |
| 52 | + repo: context.repo.repo, |
| 53 | + tag_name: '${{ steps.get_version.outputs.VERSION }}', |
| 54 | + name: 'YAMLScript ${{ steps.get_version.outputs.VERSION }}', |
| 55 | + body: releaseNotes, |
| 56 | + draft: false, |
| 57 | + prerelease: false |
| 58 | + }); |
| 59 | +
|
| 60 | + core.setOutput('id', release.data.id); |
| 61 | + core.setOutput('upload_url', release.data.upload_url); |
| 62 | + console.log(`Created release with ID: ${release.data.id}`); |
| 63 | +
|
| 64 | + build-binaries: |
| 65 | + name: Build ${{ matrix.platform }} |
| 66 | + needs: create-release |
| 67 | + runs-on: ${{ matrix.os }} |
| 68 | + strategy: |
| 69 | + fail-fast: false |
| 70 | + matrix: |
| 71 | + include: |
| 72 | + - os: ubuntu-latest |
| 73 | + arch: x64 |
| 74 | + platform: linux-x64 |
| 75 | + qemu: false |
| 76 | + - os: ubuntu-latest |
| 77 | + arch: arm64 |
| 78 | + platform: linux-aarch64 |
| 79 | + qemu: true |
| 80 | + - os: macos-13 |
| 81 | + arch: x64 |
| 82 | + platform: macos-x64 |
| 83 | + qemu: false |
| 84 | + - os: macos-14 |
| 85 | + arch: arm64 |
| 86 | + platform: macos-aarch64 |
| 87 | + qemu: false |
| 88 | + steps: |
| 89 | + - name: Checkout code |
| 90 | + uses: actions/checkout@v4 |
| 91 | + |
| 92 | + - name: Set up QEMU |
| 93 | + if: matrix.qemu |
| 94 | + uses: docker/setup-qemu-action@v3 |
| 95 | + with: |
| 96 | + platforms: linux/arm64 |
| 97 | + |
| 98 | + - name: Setup secrets file |
| 99 | + run: | |
| 100 | + mkdir -p ~/.yamlscript |
| 101 | + cat > ~/.yamlscript-secrets.yaml << 'EOF' |
| 102 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + github-username: ${{ github.repository_owner }} |
| 104 | + EOF |
| 105 | + shell: bash |
| 106 | + |
| 107 | + - name: Get version from tag |
| 108 | + id: get_version |
| 109 | + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 110 | + shell: bash |
| 111 | + |
| 112 | + - name: Build and upload release assets |
| 113 | + env: |
| 114 | + YS_RELEASE_ID: ${{ needs.create-release.outputs.release_id }} |
| 115 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + run: | |
| 117 | + echo "Building for platform: ${{ matrix.platform }}" |
| 118 | + echo "Release ID: $YS_RELEASE_ID" |
| 119 | + make release-assets |
| 120 | + shell: bash |
| 121 | + |
| 122 | + build-jars: |
| 123 | + name: Build JAR files |
| 124 | + needs: create-release |
| 125 | + runs-on: ubuntu-latest |
| 126 | + steps: |
| 127 | + - name: Checkout code |
| 128 | + uses: actions/checkout@v4 |
| 129 | + |
| 130 | + - name: Setup secrets file |
| 131 | + run: | |
| 132 | + mkdir -p ~/.yamlscript |
| 133 | + cat > ~/.yamlscript-secrets.yaml << 'EOF' |
| 134 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 135 | + github-username: ${{ github.repository_owner }} |
| 136 | + EOF |
| 137 | +
|
| 138 | + - name: Build JAR files |
| 139 | + env: |
| 140 | + YS_RELEASE_ID: ${{ needs.create-release.outputs.release_id }} |
| 141 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 142 | + run: | |
| 143 | + echo "Building JAR files" |
| 144 | + # The release-assets target should handle JAR builds |
| 145 | + # If JARs are built separately from binaries, adjust this |
| 146 | + make release-assets |
| 147 | +
|
| 148 | + publish-bindings: |
| 149 | + name: Publish Language Bindings |
| 150 | + needs: [create-release, build-binaries, build-jars] |
| 151 | + runs-on: ubuntu-latest |
| 152 | + steps: |
| 153 | + - name: Checkout code |
| 154 | + uses: actions/checkout@v4 |
| 155 | + |
| 156 | + - name: Setup secrets file |
| 157 | + run: | |
| 158 | + mkdir -p ~/.yamlscript |
| 159 | + cat > ~/.yamlscript-secrets.yaml << 'EOF' |
| 160 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 161 | + github-username: ${{ github.repository_owner }} |
| 162 | + clojars-username: ${{ secrets.CLOJARS_USERNAME }} |
| 163 | + clojars-password: ${{ secrets.CLOJARS_PASSWORD }} |
| 164 | + crates-io-token: ${{ secrets.CRATES_IO_TOKEN }} |
| 165 | + npm-token: ${{ secrets.NPM_TOKEN }} |
| 166 | + pypi-token: ${{ secrets.PYPI_TOKEN }} |
| 167 | + rubygems-api-key: ${{ secrets.RUBYGEMS_API_KEY }} |
| 168 | + nuget-api-key: ${{ secrets.NUGET_API_KEY }} |
| 169 | + hackage-token: ${{ secrets.HACKAGE_TOKEN }} |
| 170 | + cpan-username: ${{ secrets.CPAN_USERNAME }} |
| 171 | + cpan-password: ${{ secrets.CPAN_PASSWORD }} |
| 172 | + crystal-token: ${{ secrets.CRYSTAL_TOKEN }} |
| 173 | + julia-token: ${{ secrets.JULIA_TOKEN }} |
| 174 | + raku-token: ${{ secrets.RAKU_TOKEN }} |
| 175 | + EOF |
| 176 | +
|
| 177 | + - name: Publish Clojure binding |
| 178 | + run: make -C clojure release |
| 179 | + continue-on-error: true |
| 180 | + |
| 181 | + - name: Publish Crystal binding |
| 182 | + run: make -C crystal release |
| 183 | + continue-on-error: true |
| 184 | + |
| 185 | + - name: Publish C# binding |
| 186 | + run: make -C csharp release |
| 187 | + continue-on-error: true |
| 188 | + |
| 189 | + - name: Publish Go binding |
| 190 | + run: make -C go release |
| 191 | + continue-on-error: true |
| 192 | + |
| 193 | + - name: Publish Haskell binding |
| 194 | + run: make -C haskell release |
| 195 | + continue-on-error: true |
| 196 | + |
| 197 | + - name: Publish Java binding |
| 198 | + run: make -C java release |
| 199 | + continue-on-error: true |
| 200 | + |
| 201 | + - name: Publish Julia binding |
| 202 | + run: make -C julia release |
| 203 | + continue-on-error: true |
| 204 | + |
| 205 | + - name: Publish Lua binding |
| 206 | + run: make -C lua release |
| 207 | + continue-on-error: true |
| 208 | + |
| 209 | + - name: Publish NodeJS binding |
| 210 | + run: make -C nodejs release |
| 211 | + continue-on-error: true |
| 212 | + |
| 213 | + - name: Publish Perl binding |
| 214 | + run: make -C perl release |
| 215 | + continue-on-error: true |
| 216 | + |
| 217 | + - name: Publish Perl-Alien binding |
| 218 | + run: make -C perl-alien release |
| 219 | + continue-on-error: true |
| 220 | + |
| 221 | + - name: Publish PHP binding |
| 222 | + run: make -C php release |
| 223 | + continue-on-error: true |
| 224 | + |
| 225 | + - name: Publish Python binding |
| 226 | + run: make -C python release |
| 227 | + continue-on-error: true |
| 228 | + |
| 229 | + - name: Publish Raku binding |
| 230 | + run: make -C raku release |
| 231 | + continue-on-error: true |
| 232 | + |
| 233 | + - name: Publish Ruby binding |
| 234 | + run: make -C ruby release |
| 235 | + continue-on-error: true |
| 236 | + |
| 237 | + - name: Publish Rust binding |
| 238 | + run: make -C rust release |
| 239 | + continue-on-error: true |
| 240 | + |
| 241 | + publish-website: |
| 242 | + name: Publish Website |
| 243 | + needs: [publish-bindings] |
| 244 | + runs-on: ubuntu-latest |
| 245 | + steps: |
| 246 | + - name: Checkout code |
| 247 | + uses: actions/checkout@v4 |
| 248 | + with: |
| 249 | + fetch-depth: 0 |
| 250 | + |
| 251 | + - name: Setup secrets file |
| 252 | + run: | |
| 253 | + mkdir -p ~/.yamlscript |
| 254 | + cat > ~/.yamlscript-secrets.yaml << 'EOF' |
| 255 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 256 | + github-username: ${{ github.repository_owner }} |
| 257 | + EOF |
| 258 | +
|
| 259 | + - name: Configure git |
| 260 | + run: | |
| 261 | + git config --global user.name "github-actions[bot]" |
| 262 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 263 | +
|
| 264 | + - name: Publish website |
| 265 | + env: |
| 266 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 267 | + run: | |
| 268 | + # Run the website publish step from your release script |
| 269 | + # This may need adjustment based on your actual website publish process |
| 270 | + echo "Publishing website..." |
| 271 | + # TODO: Add actual website publish command |
| 272 | + # Example: make publish-website or similar |
| 273 | +
|
| 274 | + update-homebrew: |
| 275 | + name: Update Homebrew Formula |
| 276 | + needs: [publish-bindings] |
| 277 | + runs-on: ubuntu-latest |
| 278 | + steps: |
| 279 | + - name: Checkout code |
| 280 | + uses: actions/checkout@v4 |
| 281 | + |
| 282 | + - name: Setup secrets file |
| 283 | + run: | |
| 284 | + mkdir -p ~/.yamlscript |
| 285 | + cat > ~/.yamlscript-secrets.yaml << 'EOF' |
| 286 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 287 | + github-username: ${{ github.repository_owner }} |
| 288 | + EOF |
| 289 | +
|
| 290 | + - name: Configure git |
| 291 | + run: | |
| 292 | + git config --global user.name "github-actions[bot]" |
| 293 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 294 | +
|
| 295 | + - name: Update Homebrew |
| 296 | + env: |
| 297 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 298 | + run: | |
| 299 | + echo "Updating Homebrew formula..." |
| 300 | + util/brew-update |
0 commit comments