ncipollo / release-action

An action which manages a github release

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Source code is not being updated

haidarmehsen opened this issue · comments

Describe the bug
When I do a release using this action, source code (zip and tarball) are not being updated (I could verify that by downloading them and confirming they contain older code than the code in the commit that triggered the action).

To Reproduce
This is my demo workflow, I can run it at different times and see that the artifcats get updated in the releases section but the source code does not:

Click to expand the yaml file
# This workflow releases the app to github releases section in the repository

on:
  workflow_dispatch:
  # Uncomment the following lines to enable automatic builds on push to the dev branch
  push:
    branches:
      - main
name: "Test, Build & Release Android"

jobs:
  build:
    permissions: write-all
    name: Build & Release
    runs-on: macos-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4.1.1

      # Get version and build number from pubspec.yaml
      - name: Get version name and build number
        id: get_version_name_and_code
        run: |
          version=$(grep -E '^version:' pubspec.yaml | awk -F '+' '{print $1}' | awk '{print $2}')
          version_code=$(grep -E '^version:' pubspec.yaml | awk -F '+' '{print $2}')
          echo "version_name=$version" >> $GITHUB_OUTPUT
          echo "version_code=$version_code" >> $GITHUB_OUTPUT

      # Simulate Building release artifacts for dev server
      - name: Create release artifacts for dev server
        id: create_release_artifacts_for_dev_server
        run: |
          mkdir -p build/app/outputs/flutter-apk
          mkdir -p build/app/outputs/bundle/release
          touch build/app/outputs/flutter-apk/app-release.apk
          touch build/app/outputs/bundle/release/app-release.aab
          # write some content to the files
          echo "This is a test apk file" > build/app/outputs/flutter-apk/app-release.apk
          echo "This is a test aab file" > build/app/outputs/bundle/release/app-release.aab
          
          # Rename and move the artifacts to a folder called artifacts in the root of the project:
          
          # first set version_name and version_code as variables to shorten the command
          version_name=${{ steps.get_version_name_and_code.outputs.version_name }}
          version_code=${{ steps.get_version_name_and_code.outputs.version_code }}
          
          # Create the artifacts folder and copy the artifacts to it
          mkdir -p artifacts
          cp build/app/outputs/flutter-apk/app-release.apk artifacts/app-dev-v$version_name-build-$version_code.apk
          cp build/app/outputs/bundle/release/app-release.aab artifacts/app-dev-v$version_name-build-$version_code.aab

      - name: Upload all the artifacts in the artifacts folder
        uses: actions/upload-artifact@v4.3.1
        with:
          name: app-release
          path: |
            artifacts/*

      - name: Set github release version name
        id: set_github_release_version_name
        run: |
          # first set version_name and version_code as variables to shorten the command
          version_name=${{ steps.get_version_name_and_code.outputs.version_name }}
          version_code=${{ steps.get_version_name_and_code.outputs.version_code }}
          
          echo "github_release_version_name=$version_name+$version_code" >> $GITHUB_OUTPUT

      - name: Push to Releases
        uses: ncipollo/release-action@v1.14.0
        with:
          artifacts: "artifacts/*"
          token: ${{ secrets.GITHUB_TOKEN }}
          tag: ${{ steps.set_github_release_version_name.outputs.github_release_version_name }}
          removeArtifacts: true
          replacesArtifacts: true
          allowUpdates: true
          makeLatest: true

Expected behavior
I expect that not only the artifcats to be uploaded, but the latest code in the repo also to be uploaded.

Screenshots
Screenshot 2024-03-13 at 10 10 56 AM

A couple of things here:

  1. The action does not actually control what source code gets uploaded to the release. Github determines that from the tag associated with the release.
  2. Looking at your repo, I only see a single tag. Your workflow looks like it's pulling a version from a file in your repo, then using that as the tag for the release. If that tag isn't changing I wouldn't expect the source code to change either.

Generally, releases are associated with tags. The easiest way to manage releases is via tags. You can set up your workflow to run when a new tag is pushed, then you just create a tag and push it when you want a new release. If you want that to happen whenever your main branch is updated you could have a workflow which runs, creates a new tag, then creates a release using that tag (though that will create quite a bit of noise in your repo).

@ncipollo changing the tag name worked, thank you for the suggestion and this awesome action 🙏🏻