Skip to content

Commit 24fbab5

Browse files
andreiborzamydea
andauthored
chore(action): Rework action to be a composite action (#243)
* chore(action): Rework action to be a composite action - Removed docker image and workflow around it - Externalizing `@sentry/cli` so it can be installed per-runner - Support versioning of actions publishing major, minor and patch tags allowing users to pin versions - Reduce action run time by 80% as a result Closes: #185, #193, #233 * Fix path * Add @sentry/cli as dev dep so we can build locally but have it overwritten on the CI by the install step * Improve changelog * Update .github/workflows/test.yml Co-authored-by: Francesco Gringl-Novy <[email protected]> * Remove caching of yarn cache * Remove volta in action itself * Remove fetch depths for ci tests * Pin @sentry/cli to ~2.4 * Change to `^2.4` * Read out workspace path directly in action * Add comment * Run lint and format * Add lint step to test.yml * Simplify workingDirectory checks --------- Co-authored-by: Francesco Gringl-Novy <[email protected]>
1 parent 5d153c1 commit 24fbab5

21 files changed

+124205
-512
lines changed

.craft.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,5 @@ preReleaseCommand: bash scripts/craft-pre-release.sh
44
artifactProvider:
55
name: none
66
targets:
7-
- id: release
8-
name: docker
9-
source: ghcr.io/getsentry/action-release-image
10-
target: ghcr.io/getsentry/action-release-image
11-
- id: latest
12-
name: docker
13-
source: ghcr.io/getsentry/action-release-image
14-
target: ghcr.io/getsentry/action-release-image
15-
targetFormat: '{{{target}}}:latest'
167
- name: github
178
tagPrefix: v

.dockerignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@typescript-eslint/type-annotation-spacing": "error",
4343
"@typescript-eslint/unbound-method": "error",
4444
"github/array-foreach": "off",
45+
"i18n-text/no-en": "off"
4546
},
4647
"env": {
4748
"node": true,

.github/actions/use-local-dockerfile/action.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Releases always publish a `v[major].[minor].[patch]` tag
2+
# This action creates/updates `v[major]` and `v[major].[minor]` tags
3+
name: Create release tags
4+
5+
on:
6+
release:
7+
types: [released]
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
create-tags:
14+
name: Create release tags for major and minor versions
15+
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
ref: ${{ github.event.release.tag_name }}
22+
23+
- name: Set git user to getsentry-bot
24+
run: |
25+
echo "GIT_COMMITTER_NAME=getsentry-bot" >> $GITHUB_ENV;
26+
echo "GIT_AUTHOR_NAME=getsentry-bot" >> $GITHUB_ENV;
27+
echo "[email protected]" >> $GITHUB_ENV;
28+
29+
- name: Create and push major and minor version tags
30+
run: |
31+
MAJOR_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d. -f1)
32+
MINOR_VERSION=$(echo '${{ github.event.release.tag_name }}' | cut -d. -f1-2)
33+
git tag -f $MAJOR_VERSION
34+
git tag -f $MINOR_VERSION
35+
git push -f origin $MAJOR_VERSION $MINOR_VERSION

.github/workflows/release.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
name: "Action: Prepare Release"
1+
name: Prepare Release
2+
23
on:
34
workflow_dispatch:
45
inputs:
@@ -12,10 +13,13 @@ on:
1213
description: Target branch to merge into. Uses the default branch as a fallback (optional)
1314
required: false
1415
default: master
16+
1517
jobs:
1618
release:
19+
name: Release a new version
20+
1721
runs-on: ubuntu-20.04
18-
name: 'Release a new version'
22+
1923
steps:
2024
- name: Get auth token
2125
id: token

.github/workflows/test.yml

Lines changed: 73 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,103 @@
1-
name: "integration tests"
1+
name: Integration Tests
2+
23
on:
34
pull_request:
45
paths-ignore:
5-
- '**.md'
6+
- "**.md"
67
push:
78
branches:
89
- master
10+
- release/**
11+
paths-ignore:
12+
- "**.md"
13+
914
env:
1015
# Variables defined in the repository
1116
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
12-
# For master we have an environment variable that selects the action-release project
17+
# For master, we have an environment variable that selects the action-release project
1318
# instead of action-release-prs
1419
# For other branches: https://sentry-ecosystem.sentry.io/releases/?project=4505075304693760
1520
# For master branch: https://sentry-ecosystem.sentry.io/releases/?project=6576594
1621
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
1722

1823
jobs:
24+
lint:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Install
31+
run: yarn install
32+
33+
- name: Check format
34+
run: yarn format-check
35+
36+
- name: Lint
37+
run: yarn lint
38+
39+
- name: Build
40+
run: yarn build
41+
1942
# You're welcome to make changes on this job as part of your PR in order to test out your changes
2043
# We can always undo the changes once we're satisfied with the results
2144
#
2245
# Secrets on this repo do not get shared with PRs opened on a fork, thus,
2346
# add SENTRY_AUTH_TOKEN as a secret to your fork if you want to use this job.
24-
# Checkout the README.md on how to create the internal integration (read: auth token)
25-
create-real-release-per-push:
26-
name: "Test current action"
27-
runs-on: ubuntu-latest
28-
# XXX: This job will fail for forks, skip step on forks and let contributors tweak it when ready
29-
if: github.ref != 'refs/heads/master'
47+
create-staging-release-per-push:
48+
strategy:
49+
matrix:
50+
os: [ ubuntu-latest, windows-latest, macos-latest ]
51+
runs-on: ${{ matrix.os }}
52+
name: Test current action
3053
steps:
31-
- uses: actions/checkout@v3
32-
with:
33-
fetch-depth: 0
34-
# For PRs, this supports creating a release using the commits from the branch (rather than the merge commit)
35-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
36-
37-
# This allows executing the action's code in the next step rather than a specific tag
38-
- uses: './.github/actions/use-local-dockerfile'
54+
- uses: actions/checkout@v4
3955

40-
- name: Create a staging release
41-
uses: ./
42-
env:
43-
# If you want this step to be mocked you can uncomment this variable
44-
# MOCK: true
45-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
46-
SENTRY_LOG_LEVEL: debug
47-
with:
48-
ignore_missing: true
56+
- name: Create a staging release
57+
uses: ./
58+
env:
59+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
60+
SENTRY_LOG_LEVEL: debug
61+
with:
62+
ignore_missing: true
4963

50-
mock-release: # Make sure that the action works on a clean machine without building Docker
51-
name: "Build image & mock a release"
52-
runs-on: ubuntu-latest
64+
mock-release:
65+
strategy:
66+
matrix:
67+
os: [ ubuntu-latest, windows-latest, macos-latest ]
68+
runs-on: ${{ matrix.os }}
69+
name: Mock a release
5370
steps:
54-
- uses: actions/checkout@v3
55-
56-
- uses: './.github/actions/use-local-dockerfile'
71+
- uses: actions/checkout@v4
5772

58-
- name: Mock creating a Sentry release
59-
uses: ./
60-
env:
61-
MOCK: true
62-
with:
63-
environment: production
73+
- name: Mock creating a Sentry release
74+
uses: ./
75+
env:
76+
MOCK: true
77+
with:
78+
environment: production
6479

6580
mock-release-working-directory:
66-
name: "Build image & mock a release in a different working directory"
67-
runs-on: ubuntu-latest
81+
strategy:
82+
matrix:
83+
os: [ ubuntu-latest, windows-latest, macos-latest ]
84+
runs-on: ${{ matrix.os }}
85+
name: Mock a release in a different working directory
6886
steps:
69-
- name: Checkout directory we'll be running from
70-
uses: actions/checkout@v3
71-
with:
72-
path: main/
73-
74-
- name: Checkout directory we'll be testing
75-
uses: actions/checkout@v3
76-
with:
77-
path: test/
87+
- name: Checkout directory we'll be running from
88+
uses: actions/checkout@v4
89+
with:
90+
path: main/
7891

79-
- uses: './main/.github/actions/use-local-dockerfile'
80-
with:
81-
working_directory: main
92+
- name: Checkout directory we'll be testing
93+
uses: actions/checkout@v4
94+
with:
95+
path: test/
8296

83-
- name: Mock creating a Sentry release in a different directory
84-
uses: ./main
85-
env:
86-
MOCK: true
87-
with:
88-
environment: production
89-
working_directory: ./test
97+
- name: Mock creating a Sentry release in a different directory
98+
uses: ./main
99+
env:
100+
MOCK: true
101+
with:
102+
environment: production
103+
working_directory: ../test

.github/workflows/verify-dist.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Inspired by @action/checkout
2+
#
3+
# Compares the checked in `dist/index.js` with the PR's `dist/index.js`
4+
# On mismatch this action fails
5+
name: Verify dist
6+
7+
on:
8+
push:
9+
branches:
10+
- master
11+
paths-ignore:
12+
- "**.md"
13+
pull_request:
14+
paths-ignore:
15+
- "**.md"
16+
17+
jobs:
18+
check-dist:
19+
name: Verify dist/index.js file
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Use volta
29+
uses: volta-cli/action@v4
30+
31+
- name: Install dependencies
32+
run: yarn install
33+
34+
- name: Rebuild dist
35+
run: yarn build
36+
37+
- name: Compare expected and actual dist
38+
run: |
39+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
40+
echo "Detected uncommitted changes after build. Did you forget to commit `dist/index.js`?"
41+
echo "Diff:"
42+
git diff
43+
exit 1
44+
fi

0 commit comments

Comments
 (0)