Skip to content

CI Release

TimoBbz edited this page Dec 15, 2021 · 3 revisions

Overview of the release job

The release job is constituted of 3 types of steps. It is run after the build and test jobs, and only when a tag is pushed.

  deploy:
    runs-on: ubuntu-latest
    if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
    needs: [build, test]

Get the artifact

The step of getting an artifact is currently achieved by fetching the artifact previously build in the build job. Since it is a different job, it has to be downloaded with the action actions/download-artifact@master, that is the conterpart of the action actions/upload-artifact@v2 (used in the build job). The .jar files are then available at the same path, as if they persisted from the build job.

    - name: Download artifact .jar
      uses: actions/download-artifact@master
      with:
        name: RiseClipse-cli.jar
        path: ${{ github.workspace }}

Create the release

A Github release is constituted of :

  • An ID
  • A name
  • An associated tag on the repository
  • Some options
  • Some assets

This step creates the release with the parameters except the files. It will allow the following steps to refer to the release with the ID. The CI uses the action actions/create-release@v1 to achieve this step. It also needs a token, but this token is available in the secrets by default. Since the release job only triggers on tags, the trigger tag is used as release tag.

    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{github.ref_name}}
        release_name: Release ${{github.ref_name}}
        draft: true
        prerelease: false

Upload the assets

For each asset (in this case the .jar files), a step using the action actions/upload-release-asset@v1 is needed. It uses the previously created, and upload the artifacts to its url. If the CI succeeds, the release will be available on the repository website.

    - name: Upload Release Asset
      id: upload-release-asset 
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }}
        asset_path: ${{ github.workspace }}/RiseClipse-cli.jar
        asset_name: RiseClipse-cli.jar
        asset_content_type: application/jar

# Customisation of the release job

The current job used has been detailed in the previous section, but it can be customized if needed

Job configuration

Steps configuration

Get the artifact

Create the release

Upload the assets

Clone this wiki locally