|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v3 |
| 14 | + |
| 15 | + |
| 16 | + - name: Extract branch name |
| 17 | + shell: bash |
| 18 | + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT |
| 19 | + id: extract_branch |
| 20 | + |
| 21 | + - name: Build the artifact |
| 22 | + run: swiftc -O main.swift -o textract |
| 23 | + |
| 24 | + - name: Upload a Build Artifact |
| 25 | + |
| 26 | + with: |
| 27 | + # Artifact name |
| 28 | + name: textract-${{ github.ref_name }} |
| 29 | + # A file, directory or wildcard pattern that describes what to upload |
| 30 | + path: textract |
| 31 | + - name: Upload artifact |
| 32 | + uses: actions/upload-artifact@v3 |
| 33 | + with: |
| 34 | + name: my-artifact |
| 35 | + path: artifact.zip |
| 36 | + - name: Generate Release Notes |
| 37 | + id: generate_release_notes |
| 38 | + run: | |
| 39 | + notes=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline) |
| 40 | + echo "::set-output name=notes::$notes" |
| 41 | + |
| 42 | + - name: Create GitHub Release |
| 43 | + id: create_release |
| 44 | + uses: actions/create-release@v1 |
| 45 | + with: |
| 46 | + tag_name: ${{ github.ref_name }} |
| 47 | + release_name: "Release ${{ github.ref_name }}" |
| 48 | + body: | |
| 49 | + Changes in this release: |
| 50 | + ${{ steps.generate_release_notes.outputs.notes }} |
| 51 | + draft: false |
| 52 | + prerelease: false |
| 53 | + |
| 54 | + - name: Download artifact |
| 55 | + uses: actions/download-artifact@v3 |
| 56 | + with: |
| 57 | + name: textract-${{ github.ref_name }} |
| 58 | + |
| 59 | + - name: Upload Artifact to Release |
| 60 | + uses: actions/upload-release-asset@v1 |
| 61 | + with: |
| 62 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 63 | + asset_path: textract |
| 64 | + asset_name: textract |
| 65 | + asset_content_type: application/octet-stream |
0 commit comments