2024-01-03 11:32:30 -05:00
|
|
|
#
|
2024-08-26 07:29:10 -04:00
|
|
|
# See also https://forgejo.org/docs/next/contributor/release/#stable-release-process
|
2024-01-03 11:32:30 -05:00
|
|
|
#
|
|
|
|
# https://codeberg.org/forgejo-integration/forgejo
|
|
|
|
#
|
|
|
|
# Builds a release from a codeberg.org/forgejo-integration tag
|
|
|
|
#
|
|
|
|
# vars.ROLE: forgejo-integration
|
|
|
|
#
|
|
|
|
# secrets.DOER: forgejo-experimental-ci
|
|
|
|
# secrets.TOKEN: <generated from codeberg.org/forgejo-experimental-ci> scope read:user, write:repository, write:package
|
|
|
|
#
|
|
|
|
# secrets.CASCADE_ORIGIN_TOKEN: <generated from codeberg.org/forgejo-experimental-ci> scope read:user, write:repository, write:issue
|
|
|
|
# secrets.CASCADE_DESTINATION_TOKEN: <generated from code.forgejo.org/forgejo-ci> scope read:user, write:repository, write:issue
|
|
|
|
# vars.CASCADE_DESTINATION_DOER: forgejo-ci
|
|
|
|
#
|
2023-06-14 07:32:20 -04:00
|
|
|
on:
|
|
|
|
push:
|
2024-02-16 14:21:18 -05:00
|
|
|
tags: 'v[0-9]+.[0-9]+.*'
|
|
|
|
branches:
|
|
|
|
- 'forgejo'
|
|
|
|
- 'v*/forgejo'
|
2023-06-14 07:32:20 -04:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
release:
|
|
|
|
runs-on: self-hosted
|
|
|
|
# root is used for testing, allow it
|
2023-12-28 11:23:09 -05:00
|
|
|
if: vars.ROLE == 'forgejo-integration' || github.repository_owner == 'root'
|
2023-06-14 07:32:20 -04:00
|
|
|
steps:
|
2024-09-30 09:08:26 -04:00
|
|
|
- uses: actions/checkout@v4
|
2024-02-18 10:05:42 -05:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-06-14 07:32:20 -04:00
|
|
|
|
|
|
|
- name: Sanitize the name of the repository
|
|
|
|
id: repository
|
|
|
|
run: |
|
|
|
|
repository="${{ github.repository }}"
|
|
|
|
echo "value=${repository##*/}" >> "$GITHUB_OUTPUT"
|
|
|
|
|
2024-09-30 08:56:08 -04:00
|
|
|
- uses: https://code.forgejo.org/actions/setup-node@v4
|
2023-06-14 07:32:20 -04:00
|
|
|
with:
|
2023-12-28 11:23:09 -05:00
|
|
|
node-version: 20
|
2023-06-14 07:32:20 -04:00
|
|
|
|
2024-10-01 06:02:16 -04:00
|
|
|
- uses: https://code.forgejo.org/actions/setup-go@v5
|
2023-06-14 07:32:20 -04:00
|
|
|
with:
|
2024-08-03 03:55:09 -04:00
|
|
|
go-version-file: "go.mod"
|
2023-06-14 07:32:20 -04:00
|
|
|
|
2024-02-16 14:21:18 -05:00
|
|
|
- name: version from ref
|
|
|
|
id: release-info
|
|
|
|
shell: bash
|
2023-06-14 07:32:20 -04:00
|
|
|
run: |
|
2024-02-16 14:21:18 -05:00
|
|
|
set -x
|
|
|
|
ref="${{ github.ref }}"
|
|
|
|
if [[ $ref =~ ^refs/heads/ ]] ; then
|
2024-02-18 19:39:29 -05:00
|
|
|
if test "$ref" = "refs/heads/forgejo" ; then
|
2024-02-23 08:01:02 -05:00
|
|
|
version=$(git tag -l --sort=version:refname --merged | grep -v -e '-test$' | tail -1 | sed -E -e 's/^(v[0-9]+\.[0-9]+).*/\1/')-test
|
2024-02-18 19:39:29 -05:00
|
|
|
else
|
|
|
|
version=${ref#refs/heads/}
|
|
|
|
version=${version%/forgejo}-test
|
|
|
|
fi
|
2024-02-16 14:21:18 -05:00
|
|
|
override=true
|
|
|
|
fi
|
|
|
|
if [[ $ref =~ ^refs/tags/ ]] ; then
|
|
|
|
version=${ref#refs/tags/}
|
|
|
|
override=false
|
|
|
|
fi
|
|
|
|
if test -z "$version" ; then
|
|
|
|
echo failed to figure out the release version from the reference=$ref
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
version=${version#v}
|
2024-02-23 08:01:02 -05:00
|
|
|
git describe --exclude '*-test' --tags --always
|
2024-02-16 14:21:18 -05:00
|
|
|
echo "sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
|
|
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
|
|
echo "override=$override" >> "$GITHUB_OUTPUT"
|
2023-06-14 07:32:20 -04:00
|
|
|
|
2023-12-28 11:23:09 -05:00
|
|
|
- name: release notes
|
2023-06-14 07:32:20 -04:00
|
|
|
id: release-notes
|
|
|
|
run: |
|
2024-02-16 14:21:18 -05:00
|
|
|
anchor=${{ steps.release-info.outputs.version }}
|
2023-12-28 11:23:09 -05:00
|
|
|
anchor=${anchor//./-}
|
2023-06-14 07:32:20 -04:00
|
|
|
cat >> "$GITHUB_OUTPUT" <<EOF
|
|
|
|
value<<ENDVAR
|
2023-12-28 11:23:09 -05:00
|
|
|
See https://codeberg.org/forgejo/forgejo/src/branch/forgejo/RELEASE-NOTES.md#$anchor
|
2023-06-14 07:32:20 -04:00
|
|
|
ENDVAR
|
|
|
|
EOF
|
2024-02-18 15:44:42 -05:00
|
|
|
|
|
|
|
- name: cache node_modules
|
|
|
|
id: node
|
2024-09-30 08:06:49 -04:00
|
|
|
uses: https://code.forgejo.org/actions/cache@v4
|
2024-02-18 15:44:42 -05:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
node_modules
|
|
|
|
key: node-${{ steps.release-info.outputs.version }}
|
|
|
|
|
|
|
|
- name: skip if node cache hit
|
|
|
|
if: steps.node.outputs.cache-hit != 'true'
|
|
|
|
run: echo no hit
|
2023-06-14 07:32:20 -04:00
|
|
|
|
|
|
|
- name: Build sources
|
|
|
|
run: |
|
|
|
|
set -x
|
|
|
|
apt-get -qq install -y make
|
2024-02-16 14:21:18 -05:00
|
|
|
version=${{ steps.release-info.outputs.version }}
|
2023-06-14 07:32:20 -04:00
|
|
|
#
|
|
|
|
# Make sure all files are owned by the current user.
|
|
|
|
# When run as root `npx webpack` will assume the identity
|
|
|
|
# of the owner of the current working directory and may
|
|
|
|
# fail to create files if some sub-directories are not owned
|
|
|
|
# by the same user.
|
|
|
|
#
|
|
|
|
# Binaries:
|
|
|
|
# Node: 18.17.0 - /usr/local/node-v18.17.0-linux-x64/bin/node
|
|
|
|
# npm: 9.6.7 - /usr/local/node-v18.17.0-linux-x64/bin/npm
|
|
|
|
# Packages:
|
|
|
|
# add-asset-webpack-plugin: 2.0.1 => 2.0.1
|
|
|
|
# css-loader: 6.8.1 => 6.8.1
|
|
|
|
# esbuild-loader: 3.0.1 => 3.0.1
|
|
|
|
# license-checker-webpack-plugin: 0.2.1 => 0.2.1
|
|
|
|
# monaco-editor-webpack-plugin: 7.0.1 => 7.0.1
|
|
|
|
# vue-loader: 17.2.2 => 17.2.2
|
|
|
|
# webpack: 5.87.0 => 5.87.0
|
|
|
|
# webpack-cli: 5.1.4 => 5.1.4
|
|
|
|
#
|
|
|
|
chown -R $(id -u) .
|
|
|
|
make VERSION=$version TAGS=bindata sources-tarbal
|
|
|
|
mv dist/release release
|
|
|
|
|
|
|
|
(
|
|
|
|
tmp=$(mktemp -d)
|
|
|
|
tar --directory $tmp -zxvf release/*$version*.tar.gz
|
|
|
|
cd $tmp/*
|
|
|
|
#
|
|
|
|
# Verify `make frontend` files are available
|
|
|
|
#
|
|
|
|
test -d public/assets/css
|
|
|
|
test -d public/assets/fonts
|
|
|
|
test -d public/assets/js
|
|
|
|
#
|
|
|
|
# Verify `make generate` files are available
|
|
|
|
#
|
|
|
|
test -f modules/public/bindata.go
|
|
|
|
#
|
|
|
|
# Sanity check to verify that the source tarbal knows the
|
|
|
|
# version and is able to rebuild itself from it.
|
|
|
|
#
|
|
|
|
# When in sources the version is determined with git.
|
|
|
|
# When in the tarbal the version is determined from a VERSION file.
|
|
|
|
#
|
|
|
|
make sources-tarbal
|
|
|
|
tarbal=$(echo dist/release/*$version*.tar.gz)
|
|
|
|
if ! test -f $tarbal ; then
|
|
|
|
echo $tarbal does not exist
|
|
|
|
find dist release
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
)
|
|
|
|
|
2023-12-28 11:23:09 -05:00
|
|
|
- name: build container & release
|
2023-06-14 07:32:20 -04:00
|
|
|
if: ${{ secrets.TOKEN != '' }}
|
2024-04-17 10:36:53 -04:00
|
|
|
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5.1.1
|
2023-06-14 07:32:20 -04:00
|
|
|
with:
|
|
|
|
forgejo: "${{ env.GITHUB_SERVER_URL }}"
|
|
|
|
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
|
|
|
repository: "${{ steps.repository.outputs.value }}"
|
|
|
|
doer: "${{ secrets.DOER }}"
|
2024-02-16 14:21:18 -05:00
|
|
|
release-version: "${{ steps.release-info.outputs.version }}"
|
|
|
|
sha: "${{ steps.release-info.outputs.sha }}"
|
2023-06-14 07:32:20 -04:00
|
|
|
token: "${{ secrets.TOKEN }}"
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v6
|
|
|
|
release-notes: "${{ steps.release-notes.outputs.value }}"
|
|
|
|
binary-name: forgejo
|
2024-10-17 00:14:31 -04:00
|
|
|
binary-path: /app/gitea/gitea
|
2024-02-16 14:21:18 -05:00
|
|
|
override: "${{ steps.release-info.outputs.override }}"
|
2024-04-16 05:10:34 -04:00
|
|
|
verify-labels: "maintainer=contact@forgejo.org,org.opencontainers.image.version=${{ steps.release-info.outputs.version }}"
|
2024-02-16 14:21:18 -05:00
|
|
|
verbose: ${{ vars.VERBOSE || secrets.VERBOSE || 'false' }}
|
2023-06-14 07:32:20 -04:00
|
|
|
|
2023-12-28 11:23:09 -05:00
|
|
|
- name: build rootless container
|
2023-06-14 07:32:20 -04:00
|
|
|
if: ${{ secrets.TOKEN != '' }}
|
2024-04-17 10:36:53 -04:00
|
|
|
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v5.1.1
|
2023-06-14 07:32:20 -04:00
|
|
|
with:
|
|
|
|
forgejo: "${{ env.GITHUB_SERVER_URL }}"
|
|
|
|
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
|
|
|
repository: "${{ steps.repository.outputs.value }}"
|
|
|
|
doer: "${{ secrets.DOER }}"
|
2024-02-16 14:21:18 -05:00
|
|
|
release-version: "${{ steps.release-info.outputs.version }}"
|
|
|
|
sha: "${{ steps.release-info.outputs.sha }}"
|
2023-06-14 07:32:20 -04:00
|
|
|
token: "${{ secrets.TOKEN }}"
|
|
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v6
|
|
|
|
suffix: -rootless
|
|
|
|
dockerfile: Dockerfile.rootless
|
2024-02-16 14:21:18 -05:00
|
|
|
override: "${{ steps.release-info.outputs.override }}"
|
2024-04-16 05:10:34 -04:00
|
|
|
verify-labels: "maintainer=contact@forgejo.org,org.opencontainers.image.version=${{ steps.release-info.outputs.version }}"
|
2024-02-16 14:21:18 -05:00
|
|
|
verbose: ${{ vars.VERBOSE || secrets.VERBOSE || 'false' }}
|
2024-01-03 11:32:30 -05:00
|
|
|
|
|
|
|
- name: end-to-end tests
|
2024-10-17 00:18:14 -04:00
|
|
|
if: ${{ secrets.TOKEN != '' && vars.ROLE == 'forgejo-integration' && vars.SKIP_END_TO_END != 'true' }}
|
2024-12-09 19:03:22 -05:00
|
|
|
uses: https://code.forgejo.org/actions/cascading-pr@v2.1.1
|
2024-01-03 11:32:30 -05:00
|
|
|
with:
|
|
|
|
origin-url: ${{ env.GITHUB_SERVER_URL }}
|
|
|
|
origin-repo: ${{ github.repository }}
|
|
|
|
origin-token: ${{ secrets.CASCADE_ORIGIN_TOKEN }}
|
|
|
|
origin-ref: refs/heads/forgejo
|
|
|
|
destination-url: https://code.forgejo.org
|
|
|
|
destination-fork-repo: ${{ vars.CASCADE_DESTINATION_DOER }}/end-to-end
|
|
|
|
destination-repo: forgejo/end-to-end
|
2024-03-20 15:20:42 -04:00
|
|
|
destination-branch: main
|
2024-01-03 11:32:30 -05:00
|
|
|
destination-token: ${{ secrets.CASCADE_DESTINATION_TOKEN }}
|
|
|
|
update: .forgejo/cascading-release-end-to-end
|
2024-02-18 06:52:24 -05:00
|
|
|
|
|
|
|
- name: copy to experimental
|
|
|
|
if: vars.ROLE == 'forgejo-integration' && secrets.TOKEN != ''
|
|
|
|
run: |
|
|
|
|
if test "${{ vars.VERBOSE }}" = true ; then
|
|
|
|
set -x
|
|
|
|
fi
|
|
|
|
tag=v${{ steps.release-info.outputs.version }}
|
|
|
|
url=https://any:${{ secrets.TOKEN }}@codeberg.org
|
|
|
|
if test "${{ steps.release-info.outputs.override }}" = "true" ; then
|
|
|
|
curl -sS -X DELETE $url/api/v1/repos/forgejo-experimental/forgejo/releases/tags/$tag > /dev/null
|
|
|
|
curl -sS -X DELETE $url/api/v1/repos/forgejo-experimental/forgejo/tags/$tag > /dev/null
|
|
|
|
fi
|
|
|
|
# actions/checkout@v3 sets http.https://codeberg.org/.extraheader with the automatic token.
|
|
|
|
# Get rid of it so it does not prevent using the token that has write permissions
|
|
|
|
git config --local --unset http.https://codeberg.org/.extraheader
|
|
|
|
if test -f .git/shallow ; then
|
|
|
|
echo "unexptected .git/shallow file is present"
|
|
|
|
echo "it suggests a checkout --depth X was used which may prevent pushing the commit"
|
|
|
|
echo "it happens when actions/checkout is called without depth: 0"
|
|
|
|
fi
|
|
|
|
git push $url/forgejo-experimental/forgejo ${{ steps.release-info.outputs.sha }}:refs/tags/$tag
|