diff --git a/.github/workflows/bootstrap/action.yml b/.github/workflows/bootstrap/action.yml index 39b1ed6b4..6e8196b3f 100644 --- a/.github/workflows/bootstrap/action.yml +++ b/.github/workflows/bootstrap/action.yml @@ -15,6 +15,9 @@ outputs: agent-version: description: "The current agent version number" value: ${{ steps.dotnet.outputs.agent-version }} + major-version: + description: "The current major version number, semver" + value: ${{ steps.dotnet.outputs.major-version }} runs: using: "composite" @@ -48,9 +51,11 @@ runs: run: | dotnet --list-sdks dotnet tool restore - echo "Version Number: $(dotnet minver -t=v -p=canary.0 -v=e)" - echo "AGENT_VERSION=$(dotnet minver -t=v -p=canary.0 -v=e)" >> $GITHUB_ENV - echo "agent-version=$(dotnet minver -t=v -p=canary.0 -v=e)" >> $GITHUB_OUTPUT + AGENT_VERSION=$(dotnet minver -t=v -p=canary.0 -v=e) + echo "Version Number: ${AGENT_VERSION}" + echo "AGENT_VERSION=${AGENT_VERSION}" >> $GITHUB_ENV + echo "agent-version=${AGENT_VERSION}" >> $GITHUB_OUTPUT + echo "major-version=$(echo ${AGENT_VERSION} | cut -d"." -f1)" >> $GITHUB_OUTPUT # Setup git config diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1604d3fe5..5e208d38b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,8 @@ permissions: env: NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages + JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + SLACK_CHANNEL: "#apm-agent-dotnet" jobs: release: @@ -71,10 +73,10 @@ jobs: url: ${{ secrets.VAULT_ADDR }} roleId: ${{ secrets.VAULT_ROLE_ID }} secretId: ${{ secrets.VAULT_SECRET_ID }} - channel: "#apm-agent-dotnet" + channel: ${{ env.SLACK_CHANNEL }} message: | :large_green_circle: [${{ github.repository }}] Release *${{ github.ref_name }}* published. - Build: (<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>) + Build: (<${{ env.JOB_URL }}|here>) Release URL: ()" - if: ${{ failure() }} @@ -83,18 +85,22 @@ jobs: url: ${{ secrets.VAULT_ADDR }} roleId: ${{ secrets.VAULT_ROLE_ID }} secretId: ${{ secrets.VAULT_SECRET_ID }} - channel: "#apm-agent-dotnet" + channel: ${{ env.SLACK_CHANNEL }} message: | :large_yellow_circle: [${{ github.repository }}] Release *${{ github.ref_name }}* could not be published. - Build: (<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>) + Build: (<${{ env.JOB_URL }}|here>) release-windows: runs-on: windows-2022 needs: [ 'release'] + outputs: + agent-version: ${{ steps.bootstrap.outputs.agent-version }} + major-version: ${{ steps.bootstrap.outputs.major-version }} steps: - uses: actions/checkout@v3 - name: Bootstrap Action Workspace + id: bootstrap uses: ./.github/workflows/bootstrap with: rust: 'true' @@ -108,3 +114,46 @@ jobs: continue-on-error: true #continue for now until we see it working in action run: | gh release upload ${{ github.ref_name }} "build/output/elastic_apm_profiler_*.zip" + + post-release: + needs: [ 'release-windows'] + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_TAG: v${{ needs.release-windows.outputs.agent-version }} + NEW_BRANCH: update/${{ needs.release-windows.outputs.agent-version }} + TARGET_BRANCH: ${{ needs.release-windows.outputs.major-version }}.x + + steps: + - uses: actions/checkout@v4 + with: + depth: 0 + + - name: Create GitHub Pull Request if minor release. + run: | + echo "as long as there is a major.x branch" + existed_in_local=$(git ls-remote --heads origin ${TARGET_BRANCH}) + if [ -z ${existed_in_local} ]; then + echo -e "::warning::Target branch '${TARGET_BRANCH}' does not exist." + exit 0 + fi + git checkout ${TARGET_BRANCH} -b ${NEW_BRANCH} + git format-patch -k --stdout ${TARGET_BRANCH}...main -- docs CHANGELOG.asciidoc | git am -3 -k + git push origin ${NEW_BRANCH} + gh pr create \ + --title "post-release: ${GIT_TAG}" \ + --body "Generated automatically with ${JOB_URL}" \ + --head "elastic:${NEW_BRANCH}" \ + --base "$TARGET_BRANCH" \ + --repo "${{ github.repository }}" + + - name: Create branch if major release + run: | + echo "as long as there is no a major.x branch" + existed_in_local=$(git ls-remote --heads origin ${TARGET_BRANCH}) + if [ -n ${existed_in_local} ]; then + echo -e "::warning::Target branch '${TARGET_BRANCH}' does exist." + exit 0 + fi + git branch -D $TARGET_BRANCH + git push origin $TARGET_BRANCH diff --git a/RELEASING.md b/RELEASING.md index ab32c260a..a3371e892 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -36,14 +36,17 @@ Creating a release will trigger the [release Github Action](.github/workflows/re ### Attaching files on GitHub +> **NOTE**: The steps below are now automated with GitHub actions. + We attach 2 files to the release on GitHub: - `ElasticApmAgent_..(-)?.zip`: This is the startup-hook based agent. - `elastic_apm_profiler_..(-)?.zip`: This is the profiler-based agent. The CI currently generates 2 profiler zip files, one for Windows (with `libelastic_apm_profiler.dll`), and one for Linux (with `libelastic_apm_profiler.so`). The only difference in the zip files is the native agent, the remaining files are the same. We copy the 2 native files into a folder with the remaining files and zip that folder as `elastic_apm_profiler_..(-)?.zip` which we attach to the release. -The steps above are now automated. ### Updating the documentation +> **NOTE**: The steps below are now automated with GitHub actions. + Each major version has a `.x` branch in the repository (e.g. for major version `1` we have the branch `1.x`). In case of minor and patch releases we just need to update the `.x` branch to the currently released tag: @@ -65,6 +68,8 @@ git push --force upstream 1.x In case of a major release, we need to create the `.x` branch from the currently released tag and push the new `.x` branch. +#### For a major release + Additionally, in case of a major version release, we need to create a PR in [elastic/docs](https://github.com/elastic/docs). In this PR we need to update: