diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 71e25b73..f58f65b2 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -58,6 +58,9 @@ on: type: boolean default: false description: Fail-fast for the underlying matrix. + release_url: + type: string + description: Upload url for created release. artifact: type: string default: '{}' @@ -177,6 +180,28 @@ jobs: mkdir -p "_artifact" mv "$src" "_artifact/$dst" + # Optionally compress extracted artifact + - name: Compress Artifact + if: > + !failure() && !cancelled() + && fromJSON(inputs.artifact)[matrix.bake_target].dst + && (fromJSON(inputs.artifact)[matrix.bake_target].gzip || fromJSON(inputs.artifact)[matrix.bake_target].zstd) + + env: + dst: ${{ fromJSON(inputs.artifact)[matrix.bake_target].dst }} + gzlev: ${{ fromJSON(inputs.artifact)[matrix.bake_target].gzip }} + zstlev: ${{ fromJSON(inputs.artifact)[matrix.bake_target].zstd }} + + run: | + if test -n "$gzlev"; then + mv "_artifact/$dst" "_artifact/foo" + gzip "-$gzlev" "_artifact/foo" + mv "_artifact/foo.gz" "_artifact/$dst" + elif test -n "$zstlev"; then + zstd "-$zstlev" "_artifact/$dst" + mv "_artifact/$dst.zst" "_artifact/$dst" + fi + # Upload either artifact - name: Upload Artifact if: > @@ -199,3 +224,21 @@ jobs: with: path: _artifact/${{fromJSON(inputs.artifact)[matrix.bake_target].dst}} name: github-pages + + # Optionally upload artifact as release-artifact + - name: Upload Release Artifact + if: > + !failure() && !cancelled() + && fromJSON(inputs.artifact)[matrix.bake_target].dst + && fromJSON(inputs.artifact)[matrix.bake_target].mime + && contains(github.ref, 'refs/tags/v') + && inputs.release_url + + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + upload_url: ${{inputs.release_url}} + asset_path: _artifact/${{fromJSON(inputs.artifact)[matrix.bake_target].dst}} + asset_name: ${{github.ref_name}}-${{matrix.cargo_profile}}-${{matrix.feat_set}}-${{fromJSON(inputs.artifact)[matrix.bake_target].dst}} + asset_content_type: ${{fromJSON(inputs.artifact)[matrix.bake_target].mime || 'application/octet-stream'}} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 379ab638..a78d9584 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,7 @@ jobs: sys_targets: ${{vars.SYS_TARGETS || env.default_sys_targets}} sys_versions: ${{vars.SYS_VERSIONS || env.default_sys_versions}} machines: ${{vars.MACHINES || env.default_machines}} + release_url: ${{steps.release.outputs.upload_url}} steps: - name: Initialize Builder @@ -72,6 +73,22 @@ jobs: --name "${GITHUB_ACTOR}" \ --buildkitd-flags "--allow-insecure-entitlement network.host" + - if: > + !failure() && !cancelled() + && contains(github.ref, 'refs/tags/v') + + id: release + name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + with: + release_name: Release ${{github.ref_name}} + tag_name: ${{github.ref}} + body_path: NEWS.md + draft: ${{ contains(github.ref, '-draft') }} + prerelease: ${{ contains(github.ref, '-rc') }} + ## commented due to https://github.com/orgs/community/discussions/18001 #deps: # if: ${{fromJSON(vars.CI_VERBOSE_DEPS || 'false')}} @@ -157,6 +174,7 @@ jobs: needs: [init, lint] uses: ./.github/workflows/package.yml with: + release_url: ${{needs.init.outputs.release_url}} cargo_profiles: ${{needs.init.outputs.cargo_profiles}} feat_sets: ${{needs.init.outputs.feat_sets}} rust_toolchains: ${{needs.init.outputs.rust_toolchains}} @@ -189,6 +207,7 @@ jobs: uses: ./.github/workflows/publish.yml with: docker_repo: ${{vars.DOCKER_REPO}} + release_url: ${{needs.init.outputs.release_url}} cargo_profiles: ${{needs.init.outputs.cargo_profiles}} feat_sets: ${{needs.init.outputs.feat_sets}} rust_toolchains: ${{needs.init.outputs.rust_toolchains}} diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 7b7549e2..f76aacdc 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -35,6 +35,9 @@ on: type: string default: '[]' description: Matrix inclusions + release_url: + type: string + description: For release assets jobs: book: @@ -58,9 +61,14 @@ jobs: machines: ${{inputs.machines}} excludes: ${{inputs.excludes}} includes: ${{inputs.includes}} + release_url: ${{inputs.release_url}} artifact: > { - "book": {"dst": "book", "src": "/book", "pages": true}, + "book": { + "dst": "book", + "src": "/book", + "pages": true + } } binary: @@ -81,9 +89,15 @@ jobs: machines: ${{inputs.machines}} excludes: ${{inputs.excludes}} includes: ${{inputs.includes}} + release_url: ${{inputs.release_url}} artifact: > { - "static": {"dst": "tuwunel", "src": "/usr/bin/tuwunel" }, + "static": { + "dst": "tuwunel.zst", + "src": "/usr/bin/tuwunel", + "mime": "application/zstd", + "zstd": 11 + } } container: @@ -104,10 +118,21 @@ jobs: machines: ${{inputs.machines}} excludes: ${{inputs.excludes}} includes: ${{inputs.includes}} + release_url: ${{inputs.release_url}} artifact: > { - "docker": {"dst": "tuwunel-docker.tar.gz", "img": true }, - "oci": {"dst": "tuwunel-oci.tar.zst", "runner": true } + "docker": { + "dst": "tuwunel-docker.tar.gz", + "img": true, + "mime": "application/gzip", + "gzip": 7 + }, + "oci": { + "dst": "tuwunel-oci.tar.zst", + "runner": true, + "mime": "application/zstd", + "zstd": 11 + } } pkgs: @@ -131,10 +156,19 @@ jobs: machines: ${{inputs.machines}} excludes: ${{inputs.excludes}} includes: ${{inputs.includes}} + release_url: ${{inputs.release_url}} artifact: > { - "pkg-deb": {"dst": "tuwunel.deb", "src": "tuwunel_1.0.0-1_amd64.deb"}, - "pkg-rpm": {"dst": "tuwunel.rpm", "src": "tuwunel-1.0.0-1.x86_64.rpm"} + "pkg-deb": { + "dst": "tuwunel.deb", + "src": "tuwunel_1.0.0-1_amd64.deb", + "mime": "application/vnd.debian.binary-package" + }, + "pkg-rpm": { + "dst": "tuwunel.rpm", + "src": "tuwunel-1.0.0-1.x86_64.rpm", + "mime": "application/x-rpm" + } } check_pkgs: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3adfdd0a..2ea1de1e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,6 +2,9 @@ name: Publish on: workflow_call: + secrets: + ghcr_token: + dockerhub_token: inputs: cargo_profiles: type: string @@ -38,16 +41,17 @@ on: docker_repo: type: string description: DockerHub Repository - secrets: - ghcr_token: - dockerhub_token: + release_url: + type: string + description: For release assets jobs: documents: if: > !failure() && !cancelled() && inputs.machines - && github.ref == 'refs/heads/main' + && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v')) + && !contains(github.ref, '-draft') name: Documents runs-on: self-hosted @@ -66,6 +70,7 @@ jobs: && inputs.machines && inputs.docker_repo != '' && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/v')) + && !contains(github.ref, '-draft') name: Containers runs-on: ${{matrix.machine}} @@ -115,8 +120,8 @@ jobs: acct: ${{github.actor}} repo: ${{github.repository}} docker_repo: ${{inputs.docker_repo}} + docker_tag_preview: ${{ contains(github.ref, 'refs/tags/v') }} docker_tag_latest: ${{ contains(github.ref, 'refs/tags/v') && !contains(github.ref, '-rc') }} - docker_tag_preview: ${{ contains(github.ref, 'refs/tags/v') && contains(github.ref, '-rc') }} run: | docker/bake.sh "${{matrix.bake_target}}"