chore(release): publish release automatically with goreleaser #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test-tcloud | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - 'main' | |
| permissions: {} | |
| jobs: | |
| get_all_tcloud_releases: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| name: Fetch current list of all tcloud releases for testing | |
| outputs: | |
| releases: ${{ steps.get_tags.outputs.result }} | |
| steps: | |
| - name: Get release tags | |
| id: get_tags | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| retries: 3 | |
| script: | | |
| const response = await github.rest.repos.listReleases({owner:'thalassa-cloud',repo:'cli'}); | |
| const releases = response.data.map(release => release.tag_name); | |
| console.log("Found releases: " + releases); | |
| const min = [0, 16, 0]; | |
| const versionAtLeast = (tag) => { | |
| const core = tag.replace(/^v/, '').split(/[-+]/)[0]; | |
| const parts = core.split('.').map((x) => parseInt(x, 10) || 0); | |
| while (parts.length < 3) parts.push(0); | |
| for (let i = 0; i < 3; i++) { | |
| if (parts[i] > min[i]) return true; | |
| if (parts[i] < min[i]) return false; | |
| } | |
| return true; | |
| }; | |
| return releases.filter(versionAtLeast); | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| test_default_version_tcloud_action: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| permissions: | |
| contents: read | |
| name: Install default version tcloud and test presence in PATH | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Install tcloud | |
| uses: ./ | |
| - name: check install | |
| run: tcloud version | |
| - name: check root directory | |
| run: | | |
| if [[ $(git diff --stat) != '' ]]; then | |
| echo 'should be clean' | |
| exit 1 | |
| else | |
| exit 0 | |
| fi | |
| shell: bash | |
| test_existing_release_action: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| permissions: | |
| contents: read | |
| name: Install existing release of tcloud and test presence in path | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Install tcloud | |
| uses: thalassa-cloud/tcloud-installer@main | |
| - name: check install | |
| run: tcloud version | |
| - name: check root directory | |
| run: | | |
| if [[ $(git diff --stat) != '' ]]; then | |
| echo 'should be clean' | |
| exit 1 | |
| else | |
| exit 0 | |
| fi | |
| test_tcloud_action_custom: | |
| runs-on: ${{ matrix.os }} | |
| needs: get_all_tcloud_releases | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| tcloud_release: ${{ fromJson(needs.get_all_tcloud_releases.outputs.releases) }} | |
| permissions: | |
| contents: read | |
| name: Install tcloud ${{ matrix.tcloud_release }} on ${{ matrix.os }} and test presence in path | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Install tcloud | |
| uses: ./ | |
| with: | |
| tcloud-release: ${{ matrix.tcloud_release }} | |
| - name: check install | |
| run: tcloud version | |
| - name: check root directory | |
| run: | | |
| if [[ $(git diff --stat) != '' ]]; then | |
| echo 'should be clean' | |
| exit 1 | |
| else | |
| exit 0 | |
| fi | |
| shell: bash | |
| test_unsupported_versions: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| version: ['v999.0.0', 'v999.1.2'] | |
| permissions: {} | |
| name: Test unsupported version ${{ matrix.version }} fails on ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: install tcloud (should fail) | |
| uses: ./ | |
| with: | |
| tcloud-release: ${{ matrix.version }} | |
| continue-on-error: true | |
| id: install-attempt | |
| - name: verify installation failed | |
| shell: bash | |
| run: | | |
| if [[ "${{ steps.install-attempt.outcome }}" == "failure" ]]; then | |
| echo "✅ Installation correctly failed for unsupported version ${{ matrix.version }}" | |
| else | |
| echo "❌ Installation should have failed for unsupported version ${{ matrix.version }}" | |
| exit 1 | |
| fi | |
| test_tcloud_action_wrong: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| permissions: | |
| contents: read | |
| name: try to install a wrong tcloud | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: install tcloud | |
| uses: ./ | |
| with: | |
| tcloud-release: 'wrong' | |
| continue-on-error: true | |
| test_tcloud_action_custom_dir: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| permissions: | |
| contents: read | |
| name: install custom tcloud and test presence in directory | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: install tcloud | |
| uses: ./ | |
| with: | |
| install-dir: "$HOME/.tcloudtest" | |
| - name: check install | |
| run: tcloud version | |
| - name: check install directory | |
| run: | | |
| [[ $(dirname "$(which tcloud)") == "$HOME/.tcloudtest" ]] | |
| shell: bash | |
| - name: check root directory | |
| run: | | |
| [[ -z $(git diff --stat) ]] | |
| shell: bash | |
| test_tcloud_action_custom_dir_root: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| permissions: | |
| contents: read | |
| name: install custom tcloud and test presence in path with custom root directory | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: install tcloud | |
| uses: ./ | |
| with: | |
| install-dir: /usr/bin | |
| use-sudo: true | |
| - name: check install | |
| run: tcloud version | |
| - name: check install directory | |
| run: | | |
| [[ $(dirname "$(which tcloud)") == /usr/bin ]] | |
| shell: bash | |
| - name: check root directory | |
| run: | | |
| [[ -z $(git diff --stat) ]] | |
| shell: bash | |
| test_tcloud_with_go_install: | |
| permissions: | |
| contents: read | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: | |
| - macos-latest | |
| - ubuntu-latest | |
| - windows-latest | |
| go_version: | |
| - '1.25' | |
| - '1.26' | |
| name: try to install tcloud with go ${{ matrix.go_version }} on ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0 | |
| with: | |
| go-version: ${{ matrix.go_version }} | |
| check-latest: true | |
| - name: install tcloud | |
| uses: ./ | |
| with: | |
| tcloud-release: 'main' | |
| - name: check install | |
| run: tcloud version |