diff --git a/.github/workflows/on_release_tag_created.yaml b/.github/workflows/on_release_tag_created.yaml new file mode 100644 index 0000000..2cf0a2c --- /dev/null +++ b/.github/workflows/on_release_tag_created.yaml @@ -0,0 +1,63 @@ +name: Release a newly pushed release tag + +on: + push: + branches: + - "!*" + tags: + - "v*" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 13 + uses: actions/setup-java@v1 + with: + java-version: 13 + + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Get Version from Tag + id: get_version + uses: battila7/get-version-action@v2 + + - name: Set tag name as version + run: mvn -B versions:set -DnewVersion=${{ steps.get_version.outputs.version-without-v }} --file pom.xml + + - name: Build with Maven + run: mvn -B package --file pom.xml + + - name: TGZ up the release + run: mkdir release && mkdir release/mediatheken-dlna-bridge-${{ steps.get_version.outputs.version-without-v }} && cp -r target/*.jar target/libraries release/mediatheken-dlna-bridge-${{ steps.get_version.outputs.version-without-v }} && cd release && tar cvfz mediatheken-dlna-bridge-${{ steps.get_version.outputs.version-without-v }}.tar.gz mediatheken-dlna-bridge-${{ steps.get_version.outputs.version-without-v }} + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + body: | + Change logs are still a TODO in this project + draft: false + prerelease: true + + - 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 }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: release/mediatheken-dlna-bridge-${{ steps.get_version.outputs.version-without-v }}.tar.gz + asset_name: mediatheken-dlna-bridge-${{ steps.get_version.outputs.version-without-v }}.tar.gz + asset_content_type: application/tar+gzip