|
| 1 | +# Setting up `semantic-release` for Haskell Github Trust packages |
| 2 | + |
| 3 | +Once a version of your package has been uploaded to Hackage and the trust |
| 4 | +account has been added to the maintainers, you can use the [semantic-release |
| 5 | +action](https://github.com/cycjimmy/semantic-release-action) to publish new |
| 6 | +versions automatically. The organization already has everything configured, you |
| 7 | +only need to configure a few things. |
| 8 | + |
| 9 | +In this example, we use the `stack-upload` plugin to upload to hackage, but feel |
| 10 | +free to use the `cabal` actions if you don't like `stack`. We also use `main` as |
| 11 | +the default branch, make sure to modify the snippets if you use a different |
| 12 | +default branch name. |
| 13 | + |
| 14 | +## Install the Github App on your repository |
| 15 | +The first step is to add the [Github |
| 16 | + app](https://github.com/organizations/haskell-github-trust/settings/installations/79745966) |
| 17 | + to your repository by adding it to the selected repositories in `Repository access` |
| 18 | + |
| 19 | +## Configure `semantic-release` in your repository |
| 20 | +In your repository at the root, configure `semantic-release` by adding the |
| 21 | +`.releaserc.mjs` at the root: |
| 22 | + |
| 23 | +```javascript |
| 24 | +/** |
| 25 | + * @type {import('semantic-release').GlobalConfig} |
| 26 | + */ |
| 27 | +export default { |
| 28 | + branches: ["main"], |
| 29 | + tagFormat: "${version}", |
| 30 | + plugins: [ |
| 31 | + "semantic-release-stack-upload", |
| 32 | + ] |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +## Add the `semantic-release` action to your repository |
| 37 | +In your repository, in `.github/workflows/semantic-release.yaml`, include this snippet: |
| 38 | + |
| 39 | +```yaml |
| 40 | +--- |
| 41 | +name: Semantic release |
| 42 | +on: |
| 43 | + push: |
| 44 | + branches: |
| 45 | + - main |
| 46 | + |
| 47 | +jobs: |
| 48 | + build: |
| 49 | + name: Semantic release |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + with: |
| 54 | + persist-credentials: false |
| 55 | + |
| 56 | + - uses: actions/create-github-app-token@v2 |
| 57 | + id: app-token |
| 58 | + with: |
| 59 | + app-id: "${{ secrets.SEMANTIC_RELEASE_APP_ID }}" |
| 60 | + private-key: "${{ secrets.SEMANTIC_RELEASE_PRIVATE_KEY }}" |
| 61 | + |
| 62 | + - name: Semantic release |
| 63 | + id: semantic |
| 64 | + uses: cycjimmy/semantic-release-action@v4 |
| 65 | + env: |
| 66 | + GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}" |
| 67 | + HACKAGE_KEY: "${{ secrets.HACKAGE_TOKEN }}" |
| 68 | + |
| 69 | + with: |
| 70 | + ci: ${{ github.ref == github.event.repository.default_branch }} |
| 71 | + extra_plugins: | |
| 72 | + semantic-release-stack-upload |
| 73 | +``` |
0 commit comments