generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
ci: Add release automation #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: Create Release Pull Request | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| base-branch: | ||
| description: 'The base branch for git operations and the pull request.' | ||
| default: 'main' | ||
| required: true | ||
| release-type: | ||
| description: 'A SemVer version diff, i.e. major, minor, or patch. Mutually exclusive with "release-version".' | ||
| required: false | ||
| release-version: | ||
| description: 'A specific version to bump to. Mutually exclusive with "release-type".' | ||
| required: false | ||
|
|
||
| jobs: | ||
| create-release-pr: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: | ||
| - name: Checkout and setup environment | ||
| uses: MetaMask/action-checkout-and-setup@v2 | ||
| with: | ||
| is-high-risk-environment: true | ||
|
|
||
| # This is to guarantee that the most recent tag is fetched. This can | ||
| # be configured to a more reasonable value by consumers. | ||
| fetch-depth: 0 | ||
|
|
||
| # We check out the specified branch, which will be used as the base | ||
| # branch for all git operations and the release PR. | ||
| ref: ${{ github.event.inputs.base-branch }} | ||
|
|
||
| - uses: MetaMask/action-create-release-pr@v4 | ||
| with: | ||
| release-type: ${{ github.event.inputs.release-type }} | ||
| release-version: ${{ github.event.inputs.release-version }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| name: Publish Release | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| slack-icon-url: | ||
| required: false | ||
| type: string | ||
| default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' | ||
| slack-subteam: | ||
| required: false | ||
| type: string | ||
| default: S042S7RE4AE # @metamask-npm-publishers | ||
| slack-username: | ||
| required: false | ||
| type: string | ||
| default: 'MetaMask bot' | ||
| secrets: | ||
| SLACK_WEBHOOK_URL: | ||
| required: true | ||
|
|
||
| jobs: | ||
| announce-release: | ||
| name: Announce release | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
| - id: name-hash | ||
| name: Get Slack name and hash | ||
| shell: bash | ||
| if: inputs.slack-subteam != '' | ||
| run: | | ||
| NAME_VERSION_TEXT=$(jq --raw-output '.name + "@" + .version' package.json ) | ||
| NAME_VERSION_TEXT_STRIPPED="${NAME_VERSION_TEXT#@}" | ||
| echo "NAME_VERSION=$NAME_VERSION_TEXT_STRIPPED" >> "$GITHUB_OUTPUT" | ||
| - id: final-text | ||
| name: Get Slack final text | ||
| shell: bash | ||
| if: inputs.slack-subteam != '' | ||
| run: | | ||
| DEFAULT_TEXT="\`${{ steps.name-hash.outputs.NAME_VERSION }}\` is awaiting deployment :rocket: \n <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/|→ Click here to review deployment>" | ||
| SUBTEAM_TEXT="${{ inputs.slack-subteam }}" | ||
| FINAL_TEXT="$DEFAULT_TEXT" | ||
| if [[ ! "$SUBTEAM_TEXT" == "" ]]; then | ||
| FINAL_TEXT="<!subteam^$SUBTEAM_TEXT> $DEFAULT_TEXT" | ||
| fi | ||
| echo "FINAL_TEXT=$FINAL_TEXT" >> "$GITHUB_OUTPUT" | ||
| - name: Post to a Slack channel | ||
| if: inputs.slack-subteam != '' | ||
| uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 | ||
| with: | ||
| payload: | | ||
| { | ||
| "text": "${{ steps.final-text.outputs.FINAL_TEXT }}", | ||
| "icon_url": "${{ inputs.slack-icon-url }}", | ||
| "username": "${{ inputs.slack-username }}" | ||
| } | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
| SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | ||
| continue-on-error: true | ||
|
|
||
| publish-release: | ||
| name: Publish release | ||
| environment: npm-publish | ||
| needs: announce-release | ||
| permissions: | ||
| contents: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| # This is to guarantee that the most recent tag is fetched, which we | ||
| # need for updating the shorthand major version tag. | ||
| fetch-depth: 0 | ||
| ref: ${{ github.sha }} | ||
| - name: Publish release | ||
| uses: MetaMask/action-publish-release@v3 | ||
| id: publish-release | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Update shorthand major version tag | ||
| run: | | ||
| ./.github/workflows/scripts/update-major-version-tag.sh \ | ||
| ${{ steps.publish-release.outputs.release-version }} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -x | ||
| set -e | ||
| set -o pipefail | ||
|
|
||
| RELEASE_VERSION="${1}" | ||
|
|
||
| if [[ -z $RELEASE_VERSION ]]; then | ||
| echo "Error: No release version specified." | ||
| exit 1 | ||
| fi | ||
|
|
||
| MAJOR_VERSION_TAG="v${RELEASE_VERSION/\.*/}" | ||
|
|
||
| git config user.name github-actions | ||
| git config user.email [email protected] | ||
|
|
||
| if git show-ref --tags "$MAJOR_VERSION_TAG" --quiet; then | ||
| echo "Tag \"${MAJOR_VERSION_TAG}\" exists, attempting to delete it." | ||
| git tag --delete "$MAJOR_VERSION_TAG" | ||
| git push --delete origin "$MAJOR_VERSION_TAG" | ||
| else | ||
| echo "Tag \"${MAJOR_VERSION_TAG}\" does not exist, creating it from scratch." | ||
| fi | ||
|
|
||
| git tag "$MAJOR_VERSION_TAG" HEAD | ||
| git push --tags | ||
| echo "Updated shorthand major version tag." | ||
|
|
||
| echo "MAJOR_VERSION_TAG=$MAJOR_VERSION_TAG" >> "$GITHUB_OUTPUT" |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| [Unreleased]: https://github.com/MetaMask/github-tools/ | ||
Mrtenz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.