Skip to content

Commit

Permalink
Do not use v prefix in prepare release workflow (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
jirikuncar authored Feb 21, 2022
1 parent b008ff7 commit a6b48ff
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/prepare_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ env:
on:
workflow_dispatch:
inputs:
tag:
description: New version tag
version:
description: New version number (e.g. '1.2.3' without the 'v' prefix)
required: true

jobs:
Expand Down Expand Up @@ -37,30 +37,30 @@ jobs:
with:
ruby-version: 2.6

- name: Bump Gem version
- name: Bump version
run: |
git switch -c "release/${RELEASE_TAG}"
git switch -c "release/${RELEASE_VERSION}"
bundle install
bundle exec gem bump -v "${RELEASE_TAG#v}"
git push -f --set-upstream origin "release/${RELEASE_TAG}"
bundle exec gem bump -v "${RELEASE_VERSION}"
git push -f --set-upstream origin "release/${RELEASE_VERSION}"
env:
RELEASE_TAG: ${{ github.event.inputs.tag }}
RELEASE_VERSION: ${{ github.event.inputs.version }}

- name: Create PR
uses: actions/github-script@v5
env:
RELEASE_TAG: ${{ github.event.inputs.tag }}
RELEASE_VERSION: ${{ github.event.inputs.version }}
BASE: ${{ github.event.ref }}
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const { data: notes } = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env.RELEASE_TAG,
tag_name: `v${process.env.RELEASE_VERSION}`,
});
const today = new Date().toJSON().slice(0, 10);
const header = [`# CHANGELOG\n\n## ${process.env.RELEASE_TAG} / ${today}\n`];
const header = [`# CHANGELOG\n\n## ${process.env.RELEASE_VERSION} / ${today}\n`];
const changes = header.concat(notes.body.split("\n").slice(3));
const { data: content } = await github.rest.repos.getContent({
owner: context.repo.owner,
Expand All @@ -74,23 +74,23 @@ jobs:
const { data: head } = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `heads/release/${process.env.RELEASE_TAG}`,
ref: `heads/release/${process.env.RELEASE_VERSION}`,
});
const { data: commit } = await github.rest.repos.createOrUpdateFileContents({
owner: context.repo.owner,
repo: context.repo.repo,
message: "Update CHANGELOG",
content: Buffer.from(newContent).toString("base64"),
path: "CHANGELOG.md",
branch: `release/${process.env.RELEASE_TAG}`,
branch: `release/${process.env.RELEASE_VERSION}`,
sha: content.sha,
});
const { data: pr } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: `release/${process.env.RELEASE_TAG}`,
head: `release/${process.env.RELEASE_VERSION}`,
base: process.env.BASE,
title: `Release ${process.env.RELEASE_TAG}`,
title: `Release ${process.env.RELEASE_VERSION}`,
body: "Update CHANGELOG",
});
await github.rest.issues.addLabels({
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const tagName = process.env.RELEASE_BRANCH.split("/")[1];
const tagName = `v${process.env.RELEASE_BRANCH.split("/")[1]}`;
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CHANGELOG

## v1.7.0 / 2022-02-18
## 1.7.0 / 2022-02-18

### Fixed
* Add missing type to `CloudWorkloadSecurityAgentRuleAttributes` by @api-clients-generation-pipeline in https://github.com/DataDog/datadog-api-client-ruby/pull/743
Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ The release process is controlled and run by GitHub Actions.
### Update Changelog

1. Open [prepare release](https://github.com/DataDog/datadog-api-client-ruby/actions/workflows/prepare_release.yml) and click on `Run workflow` dropdown.
1. Enter new version identifier in the `New version tag` input box (e.g. `v1.7.0`).
1. Enter new version identifier in the `New version number` input box (e.g. `1.8.0`).
1. Trigger the action by clicking on `Run workflow` button.

### Review

1. Review the generated pull-request for `release/<New version tag>` branch.
1. Review the generated pull-request for `release/<New version number>` branch.
1. If everything is fine, merge the pull-request.
1. Check that the [release](https://github.com/DataDog/datadog-api-client-ruby/actions/workflows/release.yml) action created new release on GitHub.

Expand Down

0 comments on commit a6b48ff

Please sign in to comment.