diff --git a/.ci/bump-opbeans-ruby.yml b/.ci/bump-opbeans-ruby.yml new file mode 100644 index 0000000..8a76cec --- /dev/null +++ b/.ci/bump-opbeans-ruby.yml @@ -0,0 +1,93 @@ +--- +## Workflow to periodically check if there is an available newer APM agent version, e.g. +## "1.2.3". If so, then update to it. +name: Bump elastic-apm to latest version + +title: Bump elastic-apm to latest version + +scms: + elastic-apm-agent-ruby: + kind: github + spec: + user: '{{ requiredEnv "GIT_USER" }}' + email: '{{ requiredEnv "GIT_EMAIL" }}' + owner: elastic + repository: apm-agent-ruby + token: '{{ requiredEnv "GITHUB_TOKEN" }}' + username: '{{ requiredEnv "GIT_USER" }}' + branch: main + githubConfig: + kind: github + spec: + user: '{{ requiredEnv "GIT_USER" }}' + email: '{{ requiredEnv "GIT_EMAIL" }}' + owner: elastic + repository: opbeans-ruby + token: '{{ requiredEnv "GITHUB_TOKEN" }}' + username: '{{ requiredEnv "GIT_USER" }}' + branch: main + +actions: + opbeans-ruby: + kind: github/pullrequest + scmid: githubConfig + spec: + automerge: false + labels: + - dependencies + +sources: + elastic-apm-agent-ruby: + scmid: elastic-apm-agent-ruby + kind: gittag + spec: + versionfilter: + kind: semver + transformers: + - trimprefix: "v" + +targets: + dockerfile-label-schema: + name: Set org.label-schema.version in Dockerfile + sourceid: elastic-apm-agent-ruby + scmid: githubConfig + kind: file + spec: + file: Dockerfile + matchpattern: >- + org\.label-schema\.version="(\d+.\d+.\d+)" + replacepattern: >- + org.label-schema.version="{{ source `elastic-apm-agent-ruby` }}" + dockerfile-opencontainers: + name: Set org.opencontainers.image.version in Dockerfile + sourceid: elastic-apm-agent-ruby + scmid: githubConfig + kind: file + spec: + file: Dockerfile + matchpattern: >- + org\.opencontainers\.image\.version="(\d+.\d+.\d+)" + replacepattern: >- + org.opencontainers.image.version="{{ source `elastic-apm-agent-ruby` }}" + gemfile: + name: Install new elastic-apm pip dependency version + sourceid: elastic-apm-agent-ruby + scmid: githubConfig + kind: file + spec: + file: Gemfile + matchpattern: >- + gem 'elastic-apm', '\d+\.\d+\.\d+' + replacepattern: >- + gem 'elastic-apm', '{{ source `elastic-apm-agent-ruby` }}' + gem: + dependson: + - gemfile + name: Bump elastic-apm + sourceid: elastic-apm-agent-ruby + scmid: githubConfig + kind: shell + spec: + command: bundle update elastic-apm + environments: + - name: PATH diff --git a/.ci/bump-version.sh b/.ci/bump-version.sh deleted file mode 100755 index 78c0c9d..0000000 --- a/.ci/bump-version.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -set -euxo pipefail - -AGENT_VERSION="${1?Missing the APM ruby agent version}" - -## Normalise the agent version that it's coming from the tag name. -NEW_AGENT_VERSION=$(echo ${AGENT_VERSION} | sed 's#^v##g') - -## Gather ruby version -RUBY_VERSION=$(grep '^ruby' Gemfile | sed -E "s/.*[\"'](.+)[\"']/\1/") - -# Update elastic-apm in Gemfile -sed -ibck "s#\(gem 'elastic-apm', \)\('.*'\)\(.*\)#\1'${NEW_AGENT_VERSION}'\3#g" Gemfile - -## Bump agent version in the Dockerfile -sed -ibck "s#\(org.label-schema.version=\)\(\".*\"\)\(.*\)#\1\"${NEW_AGENT_VERSION}\"\3#g" Dockerfile -sed -ibck "s#\(org.opencontainers.image.version=\)\(\".*\"\)\(.*\)#\1\"${NEW_AGENT_VERSION}\"\3#g" Dockerfile - -## Use docker to bump the version to ensure the environment is easy to reproduce. -docker run --rm -t \ - --user $UID \ - -e LOCAL_USER_ID=$UID \ - -e HOME=/tmp \ - -e AGENT_VERSION="${NEW_AGENT_VERSION}" \ - -w /app \ - -v "$(pwd):/app" \ - ruby:${RUBY_VERSION} /bin/sh -c "set -x - # This version is fixed in the Gemfile.lock - gem install bundler -v 2.2.22 - bundle update elastic-apm" - -# Validate whether the agent version matches -git diff --name-only -S"elastic-apm (${NEW_AGENT_VERSION})" | grep Gemfile.lock && found=1 || found=0 -if [ ${found} -eq 0 ] ; then - echo 'ERROR: Agent version was not updated. See the below diff detail output:' - git diff --unified=0 Gemfile.lock - exit 1 -fi - -# Commit changes -git add Gemfile.lock Gemfile Dockerfile -git commit -m "fix(package): bump elastic-apm to version ${NEW_AGENT_VERSION}" diff --git a/.github/workflows/bump-opbeans-ruby.yml b/.github/workflows/bump-opbeans-ruby.yml new file mode 100644 index 0000000..c62ec1d --- /dev/null +++ b/.github/workflows/bump-opbeans-ruby.yml @@ -0,0 +1,27 @@ +--- +## Workflow to periodically check if there is an available newer APM agent version, e.g. +## "1.2.3". If so, then update to it and tag this repo with that version, e.g. +## "v1.2.3". +name: bump-opbeans-ruby + +on: + schedule: + - cron: '0 20 * * 6' + +permissions: + contents: read + +jobs: + bump: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7.3' + - uses: elastic/apm-pipeline-library/.github/actions/updatecli@current + with: + vaultUrl: ${{ secrets.VAULT_ADDR }} + vaultRoleId: ${{ secrets.VAULT_ROLE_ID }} + vaultSecretId: ${{ secrets.VAULT_SECRET_ID }} + pipeline: ./.ci/bump-opbeans-ruby.yml diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml new file mode 100644 index 0000000..5b02f2d --- /dev/null +++ b/.github/workflows/create-tag.yml @@ -0,0 +1,29 @@ +--- +# Takes the version of elastic-apm in the Gemfile and creates a tag +# if the tag does not exist yet. +name: create-tag + +on: + push: + branches: + - main + paths: + - Gemfile + +permissions: + contents: write + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # also fetch tags + - run: | + ELASTIC_APM_VERSION="v$(cat Gemfile | grep elastic-apm | awk 'BEGIN { FS=", " } { print $2 }' | tr -d \')" + # if the tag does not exist + if [[ ! $(git tag -l "${ELASTIC_APM_VERSION}") ]]; then + git tag ${ELASTIC_APM_VERSION} + git push origin "refs/tags/${ELASTIC_APM_VERSION}" + fi