Release YAMLScript #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release YAMLScript | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to release (e.g., 1.2.3)' | |
| required: true | |
| type: string | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| VERSION: ${{ inputs.version }} | |
| GRAALVM_VERSION: '22.3.0' | |
| JAVA_VERSION: '17' | |
| jobs: | |
| verify-release: | |
| name: Verify Release Prerequisites | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.version }} | |
| fetch-depth: 0 | |
| - name: Check tag exists | |
| run: | | |
| if ! git rev-parse "$VERSION" >/dev/null 2>&1; then | |
| echo "ERROR: Tag $VERSION does not exist" | |
| echo "Please run 'make release o=OLD n=$VERSION' locally first" | |
| exit 1 | |
| fi | |
| echo "✓ Tag $VERSION exists" | |
| - name: Check tag points to current commit | |
| run: | | |
| TAG_COMMIT=$(git rev-parse "$VERSION^{commit}") | |
| HEAD_COMMIT=$(git rev-parse HEAD) | |
| if [[ $TAG_COMMIT != $HEAD_COMMIT ]]; then | |
| echo "ERROR: Tag $VERSION does not point to HEAD" | |
| echo "Tag commit: $TAG_COMMIT" | |
| echo "HEAD commit: $HEAD_COMMIT" | |
| exit 1 | |
| fi | |
| echo "✓ Tag $VERSION points to HEAD" | |
| - name: Check no existing release with assets | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if gh release view "$VERSION" --json assets --jq '.assets | length' \ | |
| 2>/dev/null | grep -q '^[1-9]'; then | |
| echo "ERROR: Release $VERSION already has assets" | |
| echo "Delete the release first if you want to rebuild" | |
| exit 1 | |
| fi | |
| echo "✓ No existing release assets found" | |
| create-release: | |
| name: Create GitHub Release | |
| needs: verify-release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.version }} | |
| - name: Extract release notes from Changes file | |
| id: extract_notes | |
| run: | | |
| if [[ -f Changes ]]; then | |
| # Extract changes for this version from Changes file | |
| awk '/^- version: '"$VERSION"'$/,/^- version:/ { | |
| if (/^- version: '"$VERSION"'$/) next; | |
| if (/^- version:/) exit; | |
| if (/^ changes:/) next; | |
| if (/^ date:/) next; | |
| }' Changes | sed 's/^ //' > release-notes.txt | |
| if [[ ! -s release-notes.txt ]]; then | |
| echo "Release $VERSION" > release-notes.txt | |
| fi | |
| else | |
| echo "Release $VERSION" > release-notes.txt | |
| fi | |
| echo "Release notes:" | |
| cat release-notes.txt | |
| - name: Create GitHub Release | |
| id: create_release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if gh release view "$VERSION" >/dev/null 2>&1; then | |
| echo "Release $VERSION already exists, skipping creation" | |
| else | |
| gh release create "$VERSION" \ | |
| --title "$VERSION" \ | |
| --notes-file release-notes.txt \ | |
| --draft=false \ | |
| --prerelease=false | |
| fi | |
| build-linux-x64: | |
| name: Build Linux x64 | |
| needs: create-release | |
| runs-on: ubuntu-latest | |
| container: ubuntu:20.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.version }} | |
| - name: Set up GraalVM | |
| uses: graalvm/setup-graalvm@v1 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: 'graalvm' | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| native-image-job-reports: 'true' | |
| - name: Install build dependencies | |
| run: | | |
| apt-get update | |
| apt-get install -y build-essential zlib1g-dev curl git | |
| - name: Build and create release archives | |
| run: | | |
| make -C ys build | |
| make -C libys build | |
| make release-build | |
| - name: List created archives | |
| run: ls -lh ys-*.tar.xz libys-*.tar.xz | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: linux-x64 | |
| path: | | |
| ys-*.tar.xz | |
| libys-*.tar.xz | |
| retention-days: 7 | |
| build-macos-arm64: | |
| name: Build macOS ARM64 (Apple Silicon) | |
| needs: create-release | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.version }} | |
| - name: Set up GraalVM | |
| uses: graalvm/setup-graalvm@v1 | |
| with: | |
| java-version: ${{ env.JAVA_VERSION }} | |
| distribution: 'graalvm' | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| native-image-job-reports: 'true' | |
| - name: Build and create release archives | |
| run: | | |
| make -C ys build | |
| make -C libys build | |
| make release-build | |
| - name: List created archives | |
| run: ls -lh ys-*.tar.xz libys-*.tar.xz | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: macos-arm64 | |
| path: | | |
| ys-*.tar.xz | |
| libys-*.tar.xz | |
| retention-days: 7 | |
| upload-assets: | |
| name: Upload Release Assets | |
| needs: | |
| - build-linux-x64 | |
| - build-macos-arm64 | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ inputs.version }} | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Prepare release assets | |
| run: | | |
| find . -type f -name "*.tar.xz" -exec mv {} . \; | |
| ls -lh *.tar.xz | |
| - name: Upload assets to GitHub Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload "$VERSION" ys-*.tar.xz libys-*.tar.xz --clobber | |
| echo "Release $VERSION complete!" | |
| gh release view "$VERSION" |