|
| 1 | +name: release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]+.[0-9]+.[0-9]+' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + major_version: |
| 10 | + type: number |
| 11 | + required: true |
| 12 | + minor_version: |
| 13 | + type: number |
| 14 | + required: true |
| 15 | + patch_version: |
| 16 | + type: number |
| 17 | + required: true |
| 18 | + |
| 19 | +env: |
| 20 | + ARTIFACT_DIR: FritzBoxShell-${{ github.ref_name }} |
| 21 | + RELEASE_NAME: ${{ github.event_name == 'push' && github.ref_name || format('v{0}.{1}.{2}', inputs.major_version, inputs.minor_version, inputs.patch_version) }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + create-artifacts: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: setup rsync |
| 28 | + uses: GuillaumeFalourd/setup-rsync@v1.2 |
| 29 | + - name: git checkout |
| 30 | + uses: actions/checkout@v2 |
| 31 | + - name: inject version automatically |
| 32 | + run: sed -i "s|version=.*\.dev|version=$(echo "${{ env.RELEASE_NAME }}" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')|" fritzBoxShell.sh |
| 33 | + - name: create artifact directory |
| 34 | + run: | |
| 35 | + mkdir ${{ env.ARTIFACT_DIR }} |
| 36 | + rsync -arv --progress --exclude=".git*" --exclude="${{ env.ARTIFACT_DIR }}" . ${{ env.ARTIFACT_DIR }} |
| 37 | + - name: create .zip artifact |
| 38 | + uses: thedoctor0/zip-release@0.7.5 |
| 39 | + with: |
| 40 | + type: 'zip' |
| 41 | + filename: ${{ env.RELEASE_NAME }}.zip |
| 42 | + path: ./${{ env.ARTIFACT_DIR }} |
| 43 | + - name: create .tar.gz artifact |
| 44 | + uses: thedoctor0/zip-release@0.7.5 |
| 45 | + with: |
| 46 | + type: 'tar' |
| 47 | + filename: ${{ env.RELEASE_NAME }}.tar.gz |
| 48 | + path: ./${{ env.ARTIFACT_DIR }} |
| 49 | + - name: collect artifacts |
| 50 | + run: | |
| 51 | + mkdir artifacts |
| 52 | + mv ${{ env.RELEASE_NAME }}.tar.gz ${{ env.RELEASE_NAME }}.zip artifacts |
| 53 | + - name: upload artifacts |
| 54 | + # @todo replace by an action like https://github.com/marketplace/actions/gh-release |
| 55 | + uses: actions/upload-artifact@v3 |
| 56 | + with: |
| 57 | + name: ${{ env.RELEASE_NAME }} |
| 58 | + path: 'artifacts/*' |
| 59 | + - name: release |
| 60 | + uses: softprops/action-gh-release@v2 |
| 61 | + if: startsWith(github.ref, 'refs/tags/v') |
| 62 | + with: |
| 63 | + files: | |
| 64 | + artifacts/${{ env.RELEASE_NAME }}.zip |
| 65 | + artifacts/${{ env.RELEASE_NAME }}.tar.gz |
| 66 | +
|
0 commit comments