16

So im trying to implement a release section on my yml file for a generated artifact, explaining myself: i would like to add an artifact to my releases with my yml file.

Here's the only yml file am working on for an android app:

name: Android CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - run: mkdir -p app/build/outputs/apk/release
      - run: echo hello > app/build/outputs/apk/release/app-release-unsigned.apk
      - uses: actions/upload-artifact@v2
        with:
          name: my-artifact
          path: app/build/outputs/apk/release/app-release-unsigned.apk
      - name: set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - name: Permition Gradlew
        run: chmod +x gradlew
      - name: Build Gradlew
        run: ./gradlew assembleRelease



1 Answers1

3

The actions/upload-artifact@v2 Action is meant for uploading artifacts to GitHub Actions workflow runs, not for adding assets to a GitHub release. If you want to add build assets to a GitHub release, you should instead use the softprops/action-gh-release example described here. I've modified the example to match your specific scenario:

on:
  push:
    # Sequence of patterns matched against refs/tags
    tags:
    - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Upload Release Asset

jobs:
  build:
    name: Upload Release Asset
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Build project
        run: |
          mkdir -p app/build/outputs/apk/release
          echo hello > app/build/outputs/apk/release/app-release-unsigned.apk
      - name: Release with Notes
        uses: softprops/action-gh-release@v1
        with:
          files: app/build/outputs/apk/release/app-release-unsigned.apk
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

You can repeat the final step as needed with different paths for adding further artifacts to the release.

jidicula
  • 3,454
  • 1
  • 17
  • 38
  • 7
    Caution: actions/upload-release-asset@v1 is currently unmaintained. – Till Friebe Jul 25 '21 at 14:17
  • 3
    I've edited my answer to use a different action that's still actively maintained, and recommended in the now-archived `actions/upload-release-asset` README. – jidicula Jan 07 '22 at 14:44
  • What about you suggestion to repeat the last step to add more files? Would this new action work if the release is already created? – unkulunkulu Jun 29 '23 at 20:20