Generate tarball automatically on new tag

This commit is contained in:
Antoine Martin 2024-09-09 19:32:32 -04:00
parent b76ebe359a
commit 85a04f886c
Signed by: forge
GPG key ID: D62A472A4AA7D541
2 changed files with 56 additions and 31 deletions

View file

@ -6,6 +6,10 @@ on:
required: true
type: string
push:
tags:
- '*'
jobs:
build-tarball:
name: Build tarball
@ -22,15 +26,21 @@ jobs:
ref: ${{ inputs.ref_name }}
- name: Package build
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
export _cli_root=/usr/lib/dotnet
echo "Building dotnet-${{ inputs.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
echo "Compressing dotnet-${{ inputs.ref_name }}.tar.xz"
xz -T0 -9 -vv -e -c > ./dotnet-${{ inputs.ref_name }}.tar.xz < ./dotnet-${{ inputs.ref_name }}.tar
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-$CI_REF_NAME /p:TarballFilePath=$(pwd)/dotnet-$CI_REF_NAME.tar
echo "Compressing dotnet-$CI_REF_NAME.tar.xz"
xz -T0 -9 -vv -e -c > ./dotnet-$CI_REF_NAME.tar.xz < ./dotnet-$CI_REF_NAME.tar
echo "Generating sha512sum and sha256sum"
sha512sum dotnet-${{ inputs.ref_name }}.tar.xz > dotnet-${{ inputs.ref_name }}.tar.xz.sha512sum
sha256sum dotnet-${{ inputs.ref_name }}.tar.xz > dotnet-${{ inputs.ref_name }}.tar.xz.sha256sum
sha512sum dotnet-$CI_REF_NAME.tar.xz > dotnet-$CI_REF_NAME.tar.xz.sha512sum
sha256sum dotnet-$CI_REF_NAME.tar.xz > dotnet-$CI_REF_NAME.tar.xz.sha256sum
- name: Package upload
uses: forgejo/upload-artifact@v3
with:
@ -50,7 +60,6 @@ jobs:
uses: forgejo/download-artifact@v3
- name: Package deployment
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/${{ 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/${{ 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/${{ inputs.ref_name }}/dotnet-${{ inputs.ref_name}}.tar.xz.sha256sum
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.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.sha256sum ${{ github.server_url }}/api/packages/mirrors/generic/dotnet/$CI_REF_NAME/dotnet-$CI_REF_NAME.tar.xz.sha256sum

View file

@ -9,26 +9,42 @@ jobs:
name: Pull from upstream
runs-on: x86_64
container:
image: 'docker.io/node:20-bookworm'
image: alpine:latest
env:
upstream: https://github.com/dotnet/installer
tags: 'v6.0.1*'
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: |
git init --bare .
git remote add origin https://github.com/dotnet/installer
git fetch origin refs/heads/*:refs/mirror/*
git ls-remote origin refs/heads/v*/* | while read sha full_ref ; do
ref=${full_ref#refs/heads/}
git fetch origin $full_ref:refs/mirror/$ref
tag=${ref}
git fetch origin refs/tags/${tag}*:refs/mirror-tags/${tag}*
done
if test "${{ vars.TEST }}" != true ; then
token=${{ secrets.CODE_FORGEJO_TOKEN }}
destination=${{ vars.DESTINATION }}
owner=${{ vars.OWNER }}
else
token=${{ secrets.TEST_FORGEJO_TOKEN }}
destination=${{ vars.TEST_DESTINATION }}
owner=${{ vars.TEST_OWNER }}
fi
git push --force https://any:$token@$destination/$owner/dotnet-installer refs/mirror/*:refs/heads/* refs/mirror-tags/*:refs/tags/* --tags
git ls-remote $upstream "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > upstream_tags
git ls-remote ${{ github.server_url}}/${{ github.repository }} "refs/tags/$tags" | grep -v '{' | sed 's|.*/||' > destination_tags
cat upstream_tags destination_tags | tr ' ' '\n' | sort | uniq -u > missing_tags
echo "Missing tags:"
cat missing_tags
- name: Missing tag fetch
run: |
git remote add upstream $upstream
while read tag; do
git fetch upstream tag $tag --no-tags
done < missing_tags
- name: Packaging workflow injection
run: |
while read tag; do
git checkout $tag
git tag -d $tag
git checkout ci -- ./.forgejo
git config user.name "forgejo-actions[bot]"
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