Generate tarball automatically on new tag
This commit is contained in:
parent
b76ebe359a
commit
85a04f886c
2 changed files with 56 additions and 31 deletions
|
@ -6,6 +6,10 @@ on:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-tarball:
|
build-tarball:
|
||||||
name: Build tarball
|
name: Build tarball
|
||||||
|
@ -22,15 +26,21 @@ jobs:
|
||||||
ref: ${{ inputs.ref_name }}
|
ref: ${{ inputs.ref_name }}
|
||||||
- name: Package build
|
- name: Package build
|
||||||
run: |
|
run: |
|
||||||
|
if test $GITHUB_REF_NAME == "ci" ; then
|
||||||
|
CI_REF_NAME=${{ inputs.ref_name }}
|
||||||
|
else
|
||||||
|
CI_REF_NAME=$GITHUB_REF_NAME
|
||||||
|
fi
|
||||||
|
echo "CI_REF_NAME=$CI_REF_NAME" >> $GITHUB_OUTPUT
|
||||||
sed 's|<Exec Command="tar.*|<Exec Command="tar -cf $(TarballFilePath) -C $(TarballDir)/.. $([MSBuild]::MakeRelative($([System.IO.Path]::GetDirectoryName($(TarballDir))), $(TarballDir)))" />|' -i src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets
|
sed 's|<Exec Command="tar.*|<Exec Command="tar -cf $(TarballFilePath) -C $(TarballDir)/.. $([MSBuild]::MakeRelative($([System.IO.Path]::GetDirectoryName($(TarballDir))), $(TarballDir)))" />|' -i src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets
|
||||||
export _cli_root=/usr/lib/dotnet
|
export _cli_root=/usr/lib/dotnet
|
||||||
echo "Building dotnet-${{ inputs.ref_name }} tarball"
|
echo "Building dotnet-$CI_REF_NAME tarball"
|
||||||
_InitializeDotNetCli="$_cli_root" DOTNET_INSTALL_DIR="$_cli_root" DotNetBuildFromSource=true ./build.sh /p:ArcadeBuildTarball=true /p:EnableSourceLink=false /p:CheckEolTargetFramework=false /p:TarballDir=$(pwd)/dotnet-${{ inputs.ref_name }} /p:TarballFilePath=$(pwd)/dotnet-${{ inputs.ref_name }}.tar
|
_InitializeDotNetCli="$_cli_root" DOTNET_INSTALL_DIR="$_cli_root" DotNetBuildFromSource=true ./build.sh /p:ArcadeBuildTarball=true /p:EnableSourceLink=false /p:CheckEolTargetFramework=false /p:TarballDir=$(pwd)/dotnet-$CI_REF_NAME /p:TarballFilePath=$(pwd)/dotnet-$CI_REF_NAME.tar
|
||||||
echo "Compressing dotnet-${{ inputs.ref_name }}.tar.xz"
|
echo "Compressing dotnet-$CI_REF_NAME.tar.xz"
|
||||||
xz -T0 -9 -vv -e -c > ./dotnet-${{ inputs.ref_name }}.tar.xz < ./dotnet-${{ inputs.ref_name }}.tar
|
xz -T0 -9 -vv -e -c > ./dotnet-$CI_REF_NAME.tar.xz < ./dotnet-$CI_REF_NAME.tar
|
||||||
echo "Generating sha512sum and sha256sum"
|
echo "Generating sha512sum and sha256sum"
|
||||||
sha512sum dotnet-${{ inputs.ref_name }}.tar.xz > dotnet-${{ inputs.ref_name }}.tar.xz.sha512sum
|
sha512sum dotnet-$CI_REF_NAME.tar.xz > dotnet-$CI_REF_NAME.tar.xz.sha512sum
|
||||||
sha256sum dotnet-${{ inputs.ref_name }}.tar.xz > dotnet-${{ inputs.ref_name }}.tar.xz.sha256sum
|
sha256sum dotnet-$CI_REF_NAME.tar.xz > dotnet-$CI_REF_NAME.tar.xz.sha256sum
|
||||||
- name: Package upload
|
- name: Package upload
|
||||||
uses: forgejo/upload-artifact@v3
|
uses: forgejo/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
@ -50,7 +60,6 @@ jobs:
|
||||||
uses: forgejo/download-artifact@v3
|
uses: forgejo/download-artifact@v3
|
||||||
- name: Package deployment
|
- name: Package deployment
|
||||||
run: |
|
run: |
|
||||||
find .
|
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./tarball/dotnet-*.tar.xz ${{ github.server_url }}/api/packages/mirrors/generic/dotnet/$CI_REF_NAME/dotnet-$CI_REF_NAME.tar.xz
|
||||||
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./tarball/dotnet-*.tar.xz ${{ github.server_url }}/api/packages/mirrors/generic/dotnet/${{ inputs.ref_name }}/dotnet-${{ inputs.ref_name}}.tar.xz
|
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./tarball/dotnet-*.tar.xz.sha512sum ${{ github.server_url }}/api/packages/mirrors/generic/dotnet/$CI_REF_NAME/dotnet-$CI_REF_NAME.tar.xz.sha512sum
|
||||||
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./tarball/dotnet-*.tar.xz.sha512sum ${{ github.server_url }}/api/packages/mirrors/generic/dotnet/${{ inputs.ref_name }}/dotnet-${{ inputs.ref_name}}.tar.xz.sha512sum
|
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./tarball/dotnet-*.tar.xz.sha256sum ${{ github.server_url }}/api/packages/mirrors/generic/dotnet/$CI_REF_NAME/dotnet-$CI_REF_NAME.tar.xz.sha256sum
|
||||||
curl --user ${{ vars.CODE_FORGEJO_USER }}:${{ secrets.CODE_FORGEJO_TOKEN }} --upload-file ./tarball/dotnet-*.tar.xz.sha256sum ${{ github.server_url }}/api/packages/mirrors/generic/dotnet/${{ inputs.ref_name }}/dotnet-${{ inputs.ref_name}}.tar.xz.sha256sum
|
|
||||||
|
|
|
@ -9,26 +9,42 @@ jobs:
|
||||||
name: Pull from upstream
|
name: Pull from upstream
|
||||||
runs-on: x86_64
|
runs-on: x86_64
|
||||||
container:
|
container:
|
||||||
image: 'docker.io/node:20-bookworm'
|
image: alpine:latest
|
||||||
|
env:
|
||||||
|
upstream: https://github.com/dotnet/installer
|
||||||
|
tags: 'v6.0.1*'
|
||||||
steps:
|
steps:
|
||||||
- name: git mirror branches {v*/,}* & tags
|
- name: Environment setup
|
||||||
|
run: apk add grep git sed coreutils bash nodejs
|
||||||
|
- name: Fetch destination
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch_depth: 1
|
||||||
|
ref: ci
|
||||||
|
token: ${{ secrets.CODE_FORGEJO_TOKEN }}
|
||||||
|
- name: Missing tag detecting
|
||||||
run: |
|
run: |
|
||||||
git init --bare .
|
git ls-remote $upstream "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > upstream_tags
|
||||||
git remote add origin https://github.com/dotnet/installer
|
git ls-remote ${{ github.server_url}}/${{ github.repository }} "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > destination_tags
|
||||||
git fetch origin refs/heads/*:refs/mirror/*
|
cat upstream_tags destination_tags | tr ' ' '\n' | sort | uniq -u > missing_tags
|
||||||
git ls-remote origin refs/heads/v*/* | while read sha full_ref ; do
|
echo "Missing tags:"
|
||||||
ref=${full_ref#refs/heads/}
|
cat missing_tags
|
||||||
git fetch origin $full_ref:refs/mirror/$ref
|
- name: Missing tag fetch
|
||||||
tag=${ref}
|
run: |
|
||||||
git fetch origin refs/tags/${tag}*:refs/mirror-tags/${tag}*
|
git remote add upstream $upstream
|
||||||
done
|
while read tag; do
|
||||||
if test "${{ vars.TEST }}" != true ; then
|
git fetch upstream tag $tag --no-tags
|
||||||
token=${{ secrets.CODE_FORGEJO_TOKEN }}
|
done < missing_tags
|
||||||
destination=${{ vars.DESTINATION }}
|
- name: Packaging workflow injection
|
||||||
owner=${{ vars.OWNER }}
|
run: |
|
||||||
else
|
while read tag; do
|
||||||
token=${{ secrets.TEST_FORGEJO_TOKEN }}
|
git checkout $tag
|
||||||
destination=${{ vars.TEST_DESTINATION }}
|
git tag -d $tag
|
||||||
owner=${{ vars.TEST_OWNER }}
|
git checkout ci -- ./.forgejo
|
||||||
fi
|
git config user.name "forgejo-actions[bot]"
|
||||||
git push --force https://any:$token@$destination/$owner/dotnet-installer refs/mirror/*:refs/heads/* refs/mirror-tags/*:refs/tags/* --tags
|
git config user.email "dev@ayakael.net"
|
||||||
|
git commit -m 'Inject custom workflow'
|
||||||
|
git tag -a $tag -m $tag
|
||||||
|
done < missing_tags
|
||||||
|
- name: Push to destination
|
||||||
|
run: git push --force origin refs/tags/*:refs/tags/* --tags
|
||||||
|
|
Loading…
Reference in a new issue