fix(deps): update dependency @octokit/core to v6.1.3 (#671) #282
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release shared-workflows | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release-please: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4.1.3 | |
id: release | |
with: | |
config-file: release-please-config.json | |
manifest-file: .release-please-manifest.json | |
target-branch: ${{ github.ref_name }} | |
# We release full semver versions major.minor.patch. We need to make sure | |
# that v2 is updated as well as v2.0, so that people can pin to the major | |
# or major.minor versions if they want. | |
# | |
# `steps.release.outputs` will contain `<type>/<name>--release_created: | |
# true` for each component that was released. | |
# We then need to look at `<type>/<name>--tag_name to extract the tag | |
# name, which will be <name>-<semver>. From that, we can work out the | |
# major and minor tags and update them to point at the value of | |
# `<actions>/<name>--sha`. | |
- name: tag major and minor versions | |
if: steps.release.outputs.releases_created == 'true' | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
env: | |
RELEASES: ${{ toJSON(steps.release.outputs) }} | |
with: | |
script: | | |
const createOrUpdateTag = async (tag, sha) => { | |
const ref = `refs/tags/${tag}`; | |
let existingRef = null; | |
try { | |
const { data } = await github.rest.git.getRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref | |
}); | |
existingRef = data; | |
} catch (e) { | |
if (e.status !== 404) { | |
throw e; | |
} | |
} | |
if (existingRef) { | |
console.log(`Updating tag ${tag} from ${existingRef.object.sha} to ${sha}`); | |
await github.rest.git.updateRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref, | |
sha | |
}); | |
} else { | |
console.log(`Creating tag ${tag} at ${sha}`); | |
await github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref, | |
sha | |
}); | |
} | |
} | |
const rsplit = (str, sep, maxsplit) => { | |
var split = str.split(sep); | |
return maxsplit ? | |
[split.slice(0, -maxsplit).join(sep)].concat(split.slice(-maxsplit)) : | |
split; | |
} | |
const releases = JSON.parse(process.env.RELEASES); | |
// Filter `releases` to get the `*--release_created` outputs where | |
// the value is `"true"`. Then strip off that suffix to get an array | |
// of components that were released. | |
const components = Object.entries(releases) | |
.filter(([key, value]) => key.endsWith('--release_created') && value === 'true') | |
.map(([key]) => key.replace(/--release_created$/, '')); | |
console.log(`Components released: ${components.join(', ')}`); | |
for (const component of components) { | |
const tag = releases[`${component}--tag_name`]; | |
const sha = releases[`${component}--sha`]; | |
console.log(`Updating major and minor tags for ${component} to ${sha}`); | |
const [name, semver] = rsplit(tag, '-', 1); | |
const [major, minor] = semver.split('.'); | |
await createOrUpdateTag(`${name}-${major}`, sha); | |
await createOrUpdateTag(`${name}-${major}.${minor}`, sha); | |
} |