|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + packages: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + release: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 19 | + with: |
| 20 | + fetch-depth: 0 |
| 21 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + |
| 23 | + - name: Setup Bun |
| 24 | + uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 |
| 25 | + with: |
| 26 | + bun-version: latest |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: bun install |
| 30 | + |
| 31 | + - name: Type check |
| 32 | + run: bun run typecheck |
| 33 | + |
| 34 | + - name: Extract version from tag |
| 35 | + id: version |
| 36 | + run: | |
| 37 | + TAG_NAME=${GITHUB_REF#refs/tags/} |
| 38 | + VERSION=${TAG_NAME#v} |
| 39 | + MAJOR_VERSION=$(echo $VERSION | cut -d. -f1) |
| 40 | + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
| 41 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 42 | + echo "major_version=v$MAJOR_VERSION" >> $GITHUB_OUTPUT |
| 43 | +
|
| 44 | + - name: Verify package.json version matches tag |
| 45 | + run: | |
| 46 | + PACKAGE_VERSION=$(jq -r '.version' package.json) |
| 47 | + if [ "$PACKAGE_VERSION" != "${{ steps.version.outputs.version }}" ]; then |
| 48 | + echo "❌ Version mismatch: package.json has $PACKAGE_VERSION but tag is ${{ steps.version.outputs.version }}" |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | + echo "✅ Version verified: $PACKAGE_VERSION" |
| 52 | +
|
| 53 | + - name: Update major version tag |
| 54 | + run: | |
| 55 | + git config --global user.name "github-actions[bot]" |
| 56 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 57 | + git tag -f "${{ steps.version.outputs.major_version }}" -m "Release ${{ steps.version.outputs.major_version }} (latest)" |
| 58 | + git push origin "${{ steps.version.outputs.major_version }}" --force |
| 59 | +
|
| 60 | + - name: Create GitHub Release |
| 61 | + run: | |
| 62 | + # Create release body content |
| 63 | + RELEASE_BODY=$(cat << 'EOF' |
| 64 | + ## Release ${{ steps.version.outputs.tag_name }} |
| 65 | +
|
| 66 | + ### Quick Usage |
| 67 | + ```yaml |
| 68 | + - uses: augmentcode/augment-agent@${{ steps.version.outputs.tag_name }} |
| 69 | + with: |
| 70 | + augment_api_token: ${{ secrets.AUGMENT_API_TOKEN }} |
| 71 | + augment_api_url: ${{ vars.AUGMENT_API_URL }} |
| 72 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + instruction_file: /tmp/instruction.txt |
| 74 | + ``` |
| 75 | +
|
| 76 | + ### Major Version Tag |
| 77 | + You can also use the major version tag for automatic updates: |
| 78 | + ```yaml |
| 79 | + - uses: augmentcode/augment-agent@${{ steps.version.outputs.major_version }} |
| 80 | + ``` |
| 81 | +
|
| 82 | + ### Documentation |
| 83 | + - 📖 [Full Documentation](https://github.com/augmentcode/augment-agent#readme) |
| 84 | + - 🚀 [Quick Start Guide](https://github.com/augmentcode/augment-agent#quick-start) |
| 85 | + - ⚙️ [Configuration Options](https://github.com/augmentcode/augment-agent#inputs) |
| 86 | + - 💡 [Example Workflows](https://github.com/augmentcode/augment-agent#example-workflows) |
| 87 | + EOF |
| 88 | + ) |
| 89 | +
|
| 90 | + # Create the release using GitHub REST API |
| 91 | + echo "📡 Creating GitHub release..." |
| 92 | + RESPONSE=$(curl -s -w "%{http_code}" -L \ |
| 93 | + -X POST \ |
| 94 | + -H "Accept: application/vnd.github+json" \ |
| 95 | + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ |
| 96 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 97 | + https://api.github.com/repos/${{ github.repository }}/releases \ |
| 98 | + -d "$(jq -n \ |
| 99 | + --arg tag_name "${{ steps.version.outputs.tag_name }}" \ |
| 100 | + --arg name "Release ${{ steps.version.outputs.tag_name }}" \ |
| 101 | + --arg body "${RELEASE_BODY}" \ |
| 102 | + '{ |
| 103 | + "tag_name": $tag_name, |
| 104 | + "target_commitish": "main", |
| 105 | + "name": $name, |
| 106 | + "body": $body, |
| 107 | + "draft": false, |
| 108 | + "prerelease": false |
| 109 | + }')") |
| 110 | +
|
| 111 | + # Extract HTTP status code (last 3 characters) |
| 112 | + HTTP_CODE="${RESPONSE: -3}" |
| 113 | + RESPONSE_BODY="${RESPONSE%???}" |
| 114 | +
|
| 115 | + # Check if the request was successful |
| 116 | + if [ "$HTTP_CODE" -eq 201 ]; then |
| 117 | + echo "✅ Successfully created release ${{ steps.version.outputs.tag_name }}" |
| 118 | +
|
| 119 | + # Extract and display the release URL if available |
| 120 | + RELEASE_URL=$(echo "$RESPONSE_BODY" | jq -r '.html_url // empty') |
| 121 | + if [ -n "$RELEASE_URL" ]; then |
| 122 | + echo "🔗 Release URL: $RELEASE_URL" |
| 123 | + fi |
| 124 | +
|
| 125 | + echo "🎉 Release process completed successfully!" |
| 126 | + else |
| 127 | + echo "❌ Failed to create release. HTTP status: $HTTP_CODE" |
| 128 | + echo "Response: $RESPONSE_BODY" |
| 129 | + exit 1 |
| 130 | + fi |
| 131 | +
|
0 commit comments