Skip to content

chore(action): Rework action to be a composite action #243

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 15 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,5 @@ preReleaseCommand: bash scripts/craft-pre-release.sh
artifactProvider:
name: none
targets:
- id: release
name: docker
source: ghcr.io/getsentry/action-release-image
target: ghcr.io/getsentry/action-release-image
- id: latest
name: docker
source: ghcr.io/getsentry/action-release-image
target: ghcr.io/getsentry/action-release-image
targetFormat: '{{{target}}}:latest'
- name: github
tagPrefix: v
10 changes: 0 additions & 10 deletions .dockerignore

This file was deleted.

1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
"github/array-foreach": "off",
"i18n-text/no-en": "off"
},
"env": {
"node": true,
Expand Down
16 changes: 0 additions & 16 deletions .github/actions/use-local-dockerfile/action.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/build.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/create-release-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Releases always publish a `v[major].[minor].[patch]` tag
# This action creates/updates `v[major]` and `v[major].[minor]` tags
name: Create release tags
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need special handling for pre-releases here? this should not run for those I guess. Ideally we only run this if the version matches ^(\d+)\.(\d+)\.(\d+)$, I suppose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The action does not trigger on pre-releases, I figured we don't need extra tags for those?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, if that is the case, then all good!


on:
release:
types: [released]

permissions:
contents: write

jobs:
create-tags:
name: Create release tags for major and minor versions

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

- name: Set git user to getsentry-bot
run: |
echo "GIT_COMMITTER_NAME=getsentry-bot" >> $GITHUB_ENV;
echo "GIT_AUTHOR_NAME=getsentry-bot" >> $GITHUB_ENV;
echo "[email protected]" >> $GITHUB_ENV;

- name: Create and push major and minor version tags
run: |
MAJOR_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d. -f1)
MINOR_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d. -f1-2)
git tag -f $MAJOR_VERSION
git tag -f $MINOR_VERSION
git push -f origin $MAJOR_VERSION $MINOR_VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a question: this already handles previously set and pushed tags when we associate them with new commits?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, tags will be force updated and force pushed so e.g. the v1 tag will be updated to point to the tag from the craft release e.g. v1.5.4

8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: "Action: Prepare Release"
name: Prepare Release

on:
workflow_dispatch:
inputs:
Expand All @@ -12,10 +13,13 @@ on:
description: Target branch to merge into. Uses the default branch as a fallback (optional)
required: false
default: master

jobs:
release:
name: Release a new version

runs-on: ubuntu-20.04
name: 'Release a new version'

steps:
- name: Get auth token
id: token
Expand Down
132 changes: 73 additions & 59 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,103 @@
name: "integration tests"
name: Integration Tests

on:
pull_request:
paths-ignore:
- '**.md'
- "**.md"
push:
branches:
- master
- release/**
paths-ignore:
- "**.md"

env:
# Variables defined in the repository
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
# For master we have an environment variable that selects the action-release project
# For master, we have an environment variable that selects the action-release project
# instead of action-release-prs
# For other branches: https://sentry-ecosystem.sentry.io/releases/?project=4505075304693760
# For master branch: https://sentry-ecosystem.sentry.io/releases/?project=6576594
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install
run: yarn install

- name: Check format
run: yarn format-check

- name: Lint
run: yarn lint

- name: Build
run: yarn build

# You're welcome to make changes on this job as part of your PR in order to test out your changes
# We can always undo the changes once we're satisfied with the results
#
# Secrets on this repo do not get shared with PRs opened on a fork, thus,
# add SENTRY_AUTH_TOKEN as a secret to your fork if you want to use this job.
# Checkout the README.md on how to create the internal integration (read: auth token)
create-real-release-per-push:
name: "Test current action"
runs-on: ubuntu-latest
# XXX: This job will fail for forks, skip step on forks and let contributors tweak it when ready
if: github.ref != 'refs/heads/master'
create-staging-release-per-push:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
name: Test current action
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# For PRs, this supports creating a release using the commits from the branch (rather than the merge commit)
ref: ${{ github.event.pull_request.head.sha || github.sha }}

# This allows executing the action's code in the next step rather than a specific tag
- uses: './.github/actions/use-local-dockerfile'
- uses: actions/checkout@v4

- name: Create a staging release
uses: ./
env:
# If you want this step to be mocked you can uncomment this variable
# MOCK: true
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_LOG_LEVEL: debug
with:
ignore_missing: true
- name: Create a staging release
uses: ./
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_LOG_LEVEL: debug
with:
ignore_missing: true

mock-release: # Make sure that the action works on a clean machine without building Docker
name: "Build image & mock a release"
runs-on: ubuntu-latest
mock-release:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
name: Mock a release
steps:
- uses: actions/checkout@v3

- uses: './.github/actions/use-local-dockerfile'
- uses: actions/checkout@v4

- name: Mock creating a Sentry release
uses: ./
env:
MOCK: true
with:
environment: production
- name: Mock creating a Sentry release
uses: ./
env:
MOCK: true
with:
environment: production

mock-release-working-directory:
name: "Build image & mock a release in a different working directory"
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
name: Mock a release in a different working directory
steps:
- name: Checkout directory we'll be running from
uses: actions/checkout@v3
with:
path: main/

- name: Checkout directory we'll be testing
uses: actions/checkout@v3
with:
path: test/
- name: Checkout directory we'll be running from
uses: actions/checkout@v4
with:
path: main/

- uses: './main/.github/actions/use-local-dockerfile'
with:
working_directory: main
- name: Checkout directory we'll be testing
uses: actions/checkout@v4
with:
path: test/

- name: Mock creating a Sentry release in a different directory
uses: ./main
env:
MOCK: true
with:
environment: production
working_directory: ./test
- name: Mock creating a Sentry release in a different directory
uses: ./main
env:
MOCK: true
with:
environment: production
working_directory: ../test
44 changes: 44 additions & 0 deletions .github/workflows/verify-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Inspired by @action/checkout
#
# Compares the checked in `dist/index.js` with the PR's `dist/index.js`
# On mismatch this action fails
name: Verify dist

on:
push:
branches:
- master
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"

jobs:
check-dist:
name: Verify dist/index.js file

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use volta
uses: volta-cli/action@v4

- name: Install dependencies
run: yarn install

- name: Rebuild dist
run: yarn build

- name: Compare expected and actual dist
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. Did you forget to commit `dist/index.js`?"
echo "Diff:"
git diff
exit 1
fi
Loading