|
| 1 | +name: Linear Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '@currents/cmd-v*' |
| 7 | + - '@currents/jest-v*' |
| 8 | + - '@currents/node-test-reporter-v*' |
| 9 | + branches: |
| 10 | + - main |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + |
| 15 | +jobs: |
| 16 | + linear-release: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + # Main branch: sync to all package pipelines |
| 24 | + - name: Sync main branch to Linear (cmd) |
| 25 | + if: github.ref_type == 'branch' && github.ref_name == 'main' |
| 26 | + uses: linear/linear-release-action@v0 |
| 27 | + with: |
| 28 | + access_key: ${{ secrets.LINEAR_ACCESS_KEY_CMD }} |
| 29 | + |
| 30 | + - name: Sync main branch to Linear (jest) |
| 31 | + if: github.ref_type == 'branch' && github.ref_name == 'main' |
| 32 | + uses: linear/linear-release-action@v0 |
| 33 | + with: |
| 34 | + access_key: ${{ secrets.LINEAR_ACCESS_KEY_JEST }} |
| 35 | + |
| 36 | + - name: Sync main branch to Linear (node-test-reporter) |
| 37 | + if: github.ref_type == 'branch' && github.ref_name == 'main' |
| 38 | + uses: linear/linear-release-action@v0 |
| 39 | + with: |
| 40 | + access_key: ${{ secrets.LINEAR_ACCESS_KEY_NODE_TEST_REPORTER }} |
| 41 | + |
| 42 | + # Tag pushed: extract package name and version |
| 43 | + - name: Extract package and version from tag |
| 44 | + if: github.ref_type == 'tag' |
| 45 | + id: extract_tag |
| 46 | + run: | |
| 47 | + TAG="${GITHUB_REF#refs/tags/}" |
| 48 | + # Format: @currents/PACKAGE_NAME-vVERSION |
| 49 | + # Use digit anchor to correctly capture multi-hyphen package names |
| 50 | + if [[ $TAG =~ ^@currents/(.+)-v([0-9]+\..+)$ ]]; then |
| 51 | + PACKAGE="${BASH_REMATCH[1]}" |
| 52 | + VERSION="${BASH_REMATCH[2]}" |
| 53 | + echo "package=$PACKAGE" >> $GITHUB_OUTPUT |
| 54 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 55 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 56 | + else |
| 57 | + echo "Error: Tag '$TAG' does not match expected format '@currents/PACKAGE-vVERSION'" |
| 58 | + exit 1 |
| 59 | + fi |
| 60 | +
|
| 61 | + # Determine Linear access key based on package |
| 62 | + - name: Set Linear access key |
| 63 | + if: github.ref_type == 'tag' |
| 64 | + id: linear_key |
| 65 | + run: | |
| 66 | + PACKAGE="${{ steps.extract_tag.outputs.package }}" |
| 67 | + case "$PACKAGE" in |
| 68 | + cmd) |
| 69 | + echo "key=LINEAR_ACCESS_KEY_CMD" >> $GITHUB_OUTPUT |
| 70 | + ;; |
| 71 | + jest) |
| 72 | + echo "key=LINEAR_ACCESS_KEY_JEST" >> $GITHUB_OUTPUT |
| 73 | + ;; |
| 74 | + node-test-reporter) |
| 75 | + echo "key=LINEAR_ACCESS_KEY_NODE_TEST_REPORTER" >> $GITHUB_OUTPUT |
| 76 | + ;; |
| 77 | + *) |
| 78 | + echo "Error: Unknown package '$PACKAGE'" |
| 79 | + exit 1 |
| 80 | + ;; |
| 81 | + esac |
| 82 | +
|
| 83 | + # Sync tag to Linear with package-specific key |
| 84 | + - name: Sync tag to Linear |
| 85 | + if: github.ref_type == 'tag' |
| 86 | + uses: linear/linear-release-action@v0 |
| 87 | + with: |
| 88 | + access_key: ${{ secrets[steps.linear_key.outputs.key] }} |
| 89 | + version: ${{ steps.extract_tag.outputs.version }} |
0 commit comments