|
1 | 1 | # This GitHub action can publish assets for release when a tag is created. |
2 | 2 | # Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0). |
3 | 3 | # |
4 | | -# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your |
| 4 | +# This uses an action (paultyng/ghaction-import-gpg) that assumes you set your |
5 | 5 | # private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` |
6 | 6 | # secret. If you would rather own your own GPG handling, please fork this action |
7 | 7 | # or use an alternative one for key handling. |
8 | 8 | # |
9 | | -# You will need to pass the `--batch` flag to `gpg` in your signing step |
| 9 | +# You will need to pass the `--batch` flag to `gpg` in your signing step |
10 | 10 | # in `goreleaser` to indicate this is being used in a non-interactive mode. |
11 | 11 | # |
12 | 12 | name: release |
13 | 13 | on: |
14 | 14 | push: |
15 | 15 | tags: |
16 | 16 | - 'v*' |
| 17 | + |
| 18 | +concurrency: |
| 19 | + # Allow only run per ref |
| 20 | + # Mitigate https://intuit.github.io/auto/docs/welcome/quick-merge |
| 21 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 22 | + |
17 | 23 | jobs: |
18 | 24 | goreleaser: |
19 | 25 | runs-on: ubuntu-latest |
| 26 | + permissions: |
| 27 | + contents: write |
20 | 28 | steps: |
21 | 29 | - |
22 | 30 | name: Checkout |
23 | | - uses: actions/checkout@v4 |
| 31 | + uses: actions/checkout@v6 |
24 | 32 | - |
25 | 33 | name: Unshallow |
26 | 34 | run: git fetch --prune --unshallow |
27 | | - - |
28 | | - name: Set up Go |
29 | | - uses: actions/setup-go@v5 |
30 | | - with: |
31 | | - go-version: '1.24' |
32 | | - - |
33 | | - name: Import GPG key |
34 | | - id: import_gpg |
35 | | - uses: crazy-max/ghaction-import-gpg@v6.1.0 |
| 35 | + |
| 36 | + - uses: actions/setup-go@v6 |
36 | 37 | with: |
37 | | - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
38 | | - passphrase: ${{ secrets.PASSPHRASE }} |
| 38 | + cache: true |
| 39 | + cache-dependency-path: 'go.sum' |
| 40 | + go-version-file: 'go.mod' |
| 41 | + # - |
| 42 | + # name: Import GPG key |
| 43 | + # id: import_gpg |
| 44 | + # uses: crazy-max/ghaction-import-gpg@v6.1.0 |
| 45 | + # with: |
| 46 | + # gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 47 | + # passphrase: ${{ secrets.PASSPHRASE }} |
39 | 48 | - |
40 | 49 | name: Run GoReleaser |
| 50 | + id: release |
41 | 51 | uses: goreleaser/goreleaser-action@v6 |
42 | 52 | with: |
43 | 53 | version: latest |
44 | 54 | args: release --clean |
45 | 55 | env: |
46 | | - GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} |
47 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + #GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} |
| 57 | + GITHUB_TOKEN: ${{ github.token }} |
| 58 | + |
| 59 | + publish-mirror: |
| 60 | + needs: goreleaser |
| 61 | + runs-on: ubuntu-latest |
| 62 | + permissions: |
| 63 | + contents: write |
| 64 | + pages: write |
| 65 | + id-token: write |
| 66 | + environment: |
| 67 | + name: github-pages |
| 68 | + url: ${{ steps.deployment.outputs.page_url }} |
| 69 | + env: |
| 70 | + NAMESPACE: 'cyrilgdn' |
| 71 | + PROVIDER_NAME: 'postgresql' |
| 72 | + REGISTRY: 'registry.terraform.io' |
| 73 | + MIRROR_DIR: 'mirror' |
| 74 | + steps: |
| 75 | + - name: Set VERSION from tag |
| 76 | + run: | |
| 77 | + VERSION="${GITHUB_REF_NAME#v}" |
| 78 | + echo "VERSION=$VERSION" >> "$GITHUB_ENV" |
| 79 | +
|
| 80 | + - uses: actions/checkout@v6 |
| 81 | + |
| 82 | + - uses: actions/checkout@v6 |
| 83 | + with: |
| 84 | + ref: gh-pages |
| 85 | + path: gh-pages |
| 86 | + |
| 87 | + - name: Download release artifacts |
| 88 | + env: |
| 89 | + GH_TOKEN: ${{ github.token }} |
| 90 | + run: | |
| 91 | + echo "Downloading artifacts for version ${VERSION}" |
| 92 | + MIRROR_VERSION_DIR="${{env.MIRROR_DIR}}/${{env.REGISTRY}}/${{env.NAMESPACE}}/${{env.PROVIDER_NAME}}/${{env.VERSION}}" |
| 93 | +
|
| 94 | + # Create directory structure for network mirror |
| 95 | + mkdir -p "${MIRROR_VERSION_DIR}" |
| 96 | +
|
| 97 | + # Download release assets |
| 98 | + gh release download "v${VERSION}" -D "${MIRROR_VERSION_DIR}" |
| 99 | +
|
| 100 | + - name: Generate network mirror metadata |
| 101 | + run: | |
| 102 | + # Make script executable |
| 103 | + chmod +x scripts/generate-mirror-metadata.sh |
| 104 | +
|
| 105 | + # Generate metadata |
| 106 | + ./scripts/generate-mirror-metadata.sh "${VERSION}" "${NAMESPACE}" "${PROVIDER_NAME}" "${MIRROR_DIR}/${REGISTRY}" |
| 107 | +
|
| 108 | + # Update root simple index.html |
| 109 | + cp -f ./docs/mirror-index.html ${MIRROR_DIR}/index.html |
| 110 | + |
| 111 | + # Update gh-pages content |
| 112 | + cp -r ${MIRROR_DIR}/* ./gh-pages/ |
| 113 | +
|
| 114 | + - name: Commit and push to gh-pages |
| 115 | + run: | |
| 116 | + cd gh-pages |
| 117 | + git config user.name "github-actions[bot]" |
| 118 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 119 | + git add . |
| 120 | + git commit -m "Release version ${VERSION}" || echo "No changes to commit" |
| 121 | + git push origin gh-pages |
| 122 | +
|
| 123 | + - name: Setup Pages |
| 124 | + uses: actions/configure-pages@v5 |
| 125 | + |
| 126 | + - name: Upload artifact |
| 127 | + uses: actions/upload-pages-artifact@v3 |
| 128 | + with: |
| 129 | + path: ./gh-pages |
| 130 | + |
| 131 | + - name: Deploy to GitHub Pages |
| 132 | + id: deployment |
| 133 | + uses: actions/deploy-pages@v4 |
0 commit comments